Hello,
I have a form, it was working well, but not sure what happened when I click on submit I get
My questions are dynamic and look like this
my add_to_database.asp page looks like this
Line 32 is
I have a form, it was working well, but not sure what happened when I click on submit I get
Code:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/questions/add_to_database.asp, line 32
My questions are dynamic and look like this
Code:
<tr>
<td><input name="category" type="text" value="<% = rs1Guestbook("category") %>" /></td>
<td><input name="questions" type="text" value="<% = rs1Guestbook("questions") %>" /></td>
<td><input name="questionid" type="text" value="<% = rs1Guestbook("questionid") %>" /></td>
<td><input name="yesno" type="text" value="<% = rs1Guestbook("yesno") %>" /></td>
<td><input name="answer" type="text" value="<% = rs1Guestbook("answer") %>" /></td>
<td><input type="text" name="userid" value="<% = Response.Write(rs("userid"))%>" readonly="true" /></td>
</tr>
my add_to_database.asp page looks like this
Code:
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'declare your variables
Dim answerquestionid, answeruserid, yesno, answer
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
answerquestionid = Request.Form("questionid")
answeruserid = Request.Form("userid")
yesno =Request.Form("yesno")
answer =Request.Form("answer")
'declare SQL statement that will query the database
sSQL = "INSERT into answers1 (answerquestionid,answeruserid,yesno,answer) values ('" & _
answerquestionid & "', '" & answeruserid & "', '" & yesno & "', '" & answer & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("qa.mdb")
'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
'execute the SQL
connection.execute(sSQL)
'Done. Close the connection object
connection.Close
Set connection = Nothing%>
<%
Response.Redirect "[URL unfurl="true"]http://mywebsite.com"[/URL]
%>
</body>
</html>
Line 32 is
Code:
connection.execute(sSQL)