sql - I am trying to alphabetize a combo box using a query in my vb code. How do i get it to work Im having problems? -


i want know if possible somehow use query in vb code alphabetize list in combo box have dataset connected to?

here code:

private sub valuesourceavailabilitybindingnavigatorsaveitem_click(sender object, e eventargs) handles valuesourceavailabilitybindingnavigatorsaveitem.click         me.validate()         me.valuesourceavailabilitybindingsource.endedit()         me.tableadaptermanager.updateall(me.valuetrackerdataset)      end sub      private sub form3_load(sender object, e eventargs) handles mybase.load         'todo: line of code loads data 'valuetrackerdataset3.sa_countrycode' table. can move, or remove it, needed.         me.sa_countrycodetableadapter.fill(me.valuetrackerdataset3.sa_countrycode)         'todo: line of code loads data 'valuetrackerdataset2.sa_client' table. can move, or remove it, needed.         me.sa_clienttableadapter.fill(me.valuetrackerdataset2.sa_client)         'todo: line of code loads data 'valuetrackerdataset1.cubes' table. can move, or remove it, needed.         me.cubestableadapter.fill(me.valuetrackerdataset1.cubes)         'todo: line of code loads data 'valuetrackerdataset.valuesourceavailability' table. can move, or remove it, needed.         me.valuesourceavailabilitytableadapter.fill(me.valuetrackerdataset.valuesourceavailability)      end sub      private sub clientidcombobox_selectedindexchanged(sender object, e eventargs) handles clientidcombobox.selectedindexchanged         select * dbo.sa_client  order clientname     end sub end class 

you can't put sql statement inside of vb .net sub that. need either use linq/entity framework, or format query string , send sql. first method depend on how entity set up, while second method this:

'the sql connection dim sqllconn new sqlconnection()  'the sql command dim sqlcmd new sqlcommand()   'set connection string sqlconn.connectionstring = "connection string goes here"  'open connection      sqlconn.open  'set connection use sql command sqlcmd.connection = sqlconn  ' set query sqlcmd.commandtext = "select * dbo.sa_client order clientname"     ' stuff sqlcmd query here...   'close connection sqlconn.close()  

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -