c# - INSERT error ASP.NET -


hey error saying there wrong code when inserting database, can't quite find it. error suggests in insert statement, appears on line "cmd.executenonquery();". i'm using access database.

error: syntax error in insert statement.

con.open(); string mysql;  mysql = "insert [user](firstname,surname,age,housenumber,postcode,username,password)           values (?,?,?,?,?,?,?)"; oledbcommand cmd = new oledbcommand(mysql, con); cmd.parameters.addwithvalue("@p1", tbfirstname.text); cmd.parameters.addwithvalue("@p2", tbsurname.text); cmd.parameters.addwithvalue("@p3", int.parse(tbage.text)); cmd.parameters.addwithvalue("@p4", tbaddress1.text); cmd.parameters.addwithvalue("@p5", tbpostcode.text); cmd.parameters.addwithvalue("@p6", tbusername.text); cmd.parameters.addwithvalue("@p7", tbpassword.text); cmd.executenonquery(); con.close(); 

when add parameters value need convert matching type, if age number

cmd.parameters.addwithvalue("@p3", int.parse(tbage.text)); 

and user key word can try

"insert [user] ([firstname], [surname], [age], [housenumber], [postcode], [username], [password]) values (?,?,?,?,?,?,?)"; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -