vb.net - Using a LINQ query to populate a combo box with data from an access database -


in vb.net:

i trying populate combo box on form using data ms access database. specifically; taking of last names database, sorting them in ascending order in output list named players , adding each item in players combo box (cboplayer).

 public sub getplayers()      dim playerlastname new list(of string)     playerlastname.add("smith")     playerlastname.add("hill")     playerlastname.add("beyer")     playerlastname.add("wilson")     playerlastname.add("hudson")     playerlastname.add("van zegeren")     playerlastname.add("bibbs")     playerlastname.add("muller")     playerlastname.add("pierce")     playerlastname.add("henry")     playerlastname.add("johnston")  dim players = last in playerlastname                     order last ascending                     select last      cboplayer.items.add(players.tostring)     cboplayer.selecteditem = 0 

i know isn't correct not positive direction head in. when run program combo box populated system.linq.enumerated.

any ideas might mean or doing incorrectly?

maybe on thinking little? why not try without linq, list has sort function. bind playerlastname combobox.

    public sub getplayers()          dim playerlastname new list(of string)         playerlastname.add("smith")         playerlastname.add("hill")         playerlastname.add("beyer")         playerlastname.add("wilson")         playerlastname.add("hudson")         playerlastname.add("van zegeren")         playerlastname.add("bibbs")         playerlastname.add("muller")         playerlastname.add("pierce")         playerlastname.add("henry")         playerlastname.add("johnston")          playerlastname.sort()              cboplayers.datasource = playerlastname         cboplayers.selectedindex = -1       end sub 

edit:

or if still want linq then, need change linq return of ienumerable list...

dim players = last in playerlastname                         order last ascending                         select last  combobox1.datasource = players.tolist combobox1.selectedindex = -1 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -