Syntax Error in FROM clause - SQL Fault -
i have tried alot of changes previous posts. know cause this?
(i know code shouldn't used security point of view small local based system)
con.open(); oledbcmd.connection = con; oledbdatareader rdr = null; oledbcommand cmd = new oledbcommand("select * customers", con); rdr = cmd.executereader(); while (rdr.read()) { int32 intchech = convert.toint32(cbocustomerid.text); if (intchech == (int32)rdr.getvalue(0)) { txttitle.text = (string)rdr.getvalue(1); txtsurname.text = (string)rdr.getvalue(2); txtforename.text = (string)rdr.getvalue(3); txtaddress.text = (string)rdr.getvalue(4); txttown.text = (string)rdr.getvalue(5); txtcounty.text = (string)rdr.getvalue(6); txtpostcode.text = (string)rdr.getvalue(7); txttelephone.text = (string)rdr.getvalue(8); } } //pull database information car info string strsearch = convert.tostring(cbocustomerid.text); string strsql = @"select * hire if [customer id] = '"; oledbdataadapter dadapter1 = new oledbdataadapter(strsql, con); oledbcommandbuilder cbuidler1 = new oledbcommandbuilder(dadapter1); datatable datatable1 = new datatable(); dataset ds1 = new dataset(); dadapter1.fill(datatable1); (int = 0; < datatable1.rows.count; i++) { dghire1.rows.add(datatable1.rows[i][0], datatable1.rows[i][1], datatable1.rows[i][2], datatable1.rows[i][3], datatable1.rows[i][4]); } }
you should use code:
//pull database information car info string strsql = @"select * hire [customer id] = ?"; oledbdataadapter dadapter1 = new oledbdataadapter(strsql, con); dadapter1.selectcommand.parameters.add("[customer id]", cbocustomerid.text); oledbcommandbuilder cbuidler1 = new oledbcommandbuilder(dadapter1);
or if don't want use command parameters can use this:
string strsql = @"select * hire [customer id] = '" + cbocustomerid.text + "'"; oledbdataadapter dadapter1 = new oledbdataadapter(strsql, con); oledbcommandbuilder cbuidler1 = new oledbcommandbuilder(dadapter1);
but bad practice.
Comments
Post a Comment