sql server - How to read data from a combobox -


i want read data combobox. know how in mysql , looks this:

private sub cmbdescrip_selectedindexchanged(byval sender system.object, byval e system.eventargs) handles cmbdescrip.selectedindexchanged   dim getcategorydesc mysqlcommand = new mysqlcommand("select * category catdesc=@field2;", connection)      dim reader1 mysqldatareader      if connection.state = connectionstate.closed         connection.open()     end if      try         getcategorydesc             .parameters.addwithvalue("@field2", cmbdescrip.text)         end          reader1 = getcategorydesc.executereader()          while (reader1.read())             txtcatno.text = (reader1("catno"))         end while          getcategorydesc.dispose()         reader1.close()      catch ex exception      end try  end sub 

and yes code works i'm working sql server 2012, database i'm not familiar with. problem sql server not seem read "@field2". in mysql , that's problem right there. how work sql server?

you need change mysql command sql command... below...

    dim getcategorydesc sqlcommand = new sqlcommand("select * category catdesc=@field2;", connection)      dim reader1 sqldatareader      if connection.state = connectionstate.closed         connection.open()     end if      try         getcategorydesc             .parameters.addwithvalue("@field2", cmbdescrip.text)         end          reader1 = getcategorydesc.executereader()          while (reader1.read())             txtcatno.text = (reader1("catno"))         end while          getcategorydesc.dispose()         reader1.close()      catch ex exception      end try 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -