java - Inserting data from html to database, query error -
inserting data database html page, i've passed data jsp , java file, i'm getting error when inserting data database.
this query:
string resultquery = "insert results (hometeam, awayteam, homescore, awayscore)" + "values (+hometeam+','+awayteam+','+homescore+','+awayscore+)";
this error:
javax.servlet.servletexception: java.sql.sqlexception: [microsoft][odbc microsoft access driver] syntax error (missing operator) in query expression '+hometeam+','+awayteam+','+homescore+','+awayscore+'.
your query wrong, if of [hometeam,awayteam,homescore,awayscore] variables should rewrite query in form:
string resultquery = "insert results (hometeam, awayteam, homescore, awayscore)" + "values ('"+hometeam+"','"+awayteam+"','"+homescore+"','"+awayscore+"')";
but if not variables should write in form:
string resultquery = "insert results (hometeam, awayteam, homescore, awayscore)" + "values ('hometeam','awayteam','homescore','awayscore')";
Comments
Post a Comment