I am attempting to pass a text box value into a SQL query, something which just does not want to work for me. The error I receive is ‘End of statement expected.’
I presume it is a syntax error on my behalf, I am brand new to ASP and would be grateful if someone could point out where I am going wrong. Below is the code that is causing the problem:
queryCourse = "INSERT INTO users ( [name] ) VALUES ('" + queryCourse += textbox1.text + "');"
I am able to insert hard coded value into the database using this statement so I know that my database connection is not a problem, therefore I presume it is a problem with possibly the concatenation or the way I am referring to the text box.
Thanks in advance.
It’s the code
queryCourse += textbox1.text, remove the “queryCourse +=” part and then try it. Unless you actually want to concatenate queryCourse and textbox1.text, in which case remove the “=” (which I suspect you don’t, given that you’re setting queryCourse to be the SQL you wish to execute).In other words, your code should read: