c# - There was a error parsing the query. [ Token line number = 1,Token line offset = 52,Token in error = ) ] -
while trying insert data sql db following error sqlceexception unhandled:there error parsing query. [ token line number = 1,token line offset = 52,token in error = ) ] line of code retrieving data table customerinfo is
sqlceconnection con = new sqlceconnection("data source = ward.sdf;password=wardrobe"); con.open(); sqlcecommand com = con.createcommand(); com.commandtext= "select name customerinfo [id] =" + textbox1.text; sqlcedatareader reader = com.executereader(); reader.read(); textbox2.text = reader.getvalue(0).tostring();
i trying data database , put in textbox. error apparently line 5.
without knowing datatype field id difficult give correct answer. supposing field of text type should code with
com.commandtext= "select name customerinfo id =@id"; com.parameters.addwithvalue("@id", textbox1.text); sqlcedatareader reader = com.executereader(); if(reader.read()) textbox2.text = (!reader.isdbnull(reader.getordinal("name")) ? reader[0].tostring() : string.empty);
Comments
Post a Comment