sql - string must be exactly one character long issue -


string sqlselectquery = " select * kts staffname =" + convert.tochar(textbox1.text);         sqlcommand cmd = new sqlcommand(sqlselectquery, con);         sqldatareader dr = cmd.executereader();         if (dr.read())              textbox2.text = (dr["job title"].tostring());             textbox3.text = (dr["extn"].tostring());             textbox4.text = (dr["direct no."].tostring());             textbox5.text = (dr["mobile (office)"].tostring());             textbox6.text = (dr["sno"].tostring()); 

i want load data sql server visual studio entering name of first name employee , he's job title mobile ext ....blla blla blla appear in textboxes , error string must 1 character long

you should use

convert.tostring(textbox1.text); 

instead of

convert.tochar(textbox1.text); 

because can't fit string char, , textbox content longer 1 character

as per @rupeshpandey answer, you're missing quote delimit string in query. instruction should be

string sqlselectquery = "select * kts staffname = '" +                         convert.tostring(textbox1.text) +                         "'"; 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -