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
Post a Comment