database - Retrieve data from Db set by combobox and display to textbox -


this code

s2="select notes atotalno =" + combobox1.selecteditem +""  dim cmd oledbcommand=new oledbcommand(s2,myconnection1)  cmd.commandtext=s2 textbox1.text=convert.toint32(cmd.executescalar()).tostring() 

and getting following error:-

erorr: data type mismatch in criteria expression

apply tostring() on selecteditem , why convert result set integer, if want show in textbox?

try this,

s2 = "select notes atotalno = "& combobox1.selecteditem.tostring() &""   dim cmd oledbcommand = new oledbcommand(s2, myconnection1)  cmd.commandtext = s2  textbox1.text = "" & cmd.executescalar() 

here resultset concatenated empty string make whole string.

if column atotalno of type varchar decorate selecteditem value single quotes. like,

s2 = "select notes atotalno = '"& combobox1.selecteditem.tostring() &"'"  

hope helps thanks.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -