By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,669 Members | 2,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,669 IT Pros & Developers. It's quick & easy.

-2147217900:Syntax error in INSERT INTO statement.

P: n/a
connection.asp:

<%
Sub RunQueryString (pSQL,parms)
on error resume next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/db/VideoBlog.mdb") & ";"
Set cmd = Server.CreateObject("ADODB.command")
With cmd
.CommandText = pSQL
.CommandType = 1
.ActiveConnection = conn
Err.clear
.Execute ,parms,128
End with
If err <0 then
Response.Write "<center><font class='error'>" & Err.number & ":" &
Err.Description & "</font></center><br>"
conn.Close
Set conn = nothing
On Error Goto 0
Response.End
End If
conn.close
set conn = nothing
End Sub
%>

survey.asp:
<!--#INCLUDE FILE="connection.asp" -->
<%
age = Trim(request.form("T1"))
gender = Trim(request.form("D1"))
educationlevel = Trim(request.form("T2"))

Question1 = Trim(request.form("R1"))
Question2 = Trim(request.form("R2"))
Question3 = Trim(request.form("R3"))
Question4 = Trim(request.form("R4"))
Question5 = Trim(request.form("R5"))
Question6 = Trim(request.form("R6"))

Food = Trim(request.form("C1"))
Books = Trim(request.form("C2"))
Travel = Trim(request.form("C3"))
Others1 = Trim(request.form("T3"))
group1 = Food & "," & Books & "," & Travel & "," & Others1

Search = Trim(request.form("C4"))
Emailing = Trim(request.form("C5"))
Subscription = Trim(request.form("C6"))
Others2 = Trim(request.form("T4"))
group2 = Search & "," & Emailing & "," & Subscription & "," &
Others2

Question9 = Trim(request.form("S1"))
Question10 = Trim(request.form("S2"))

arParms = Array(age, gender, educationlevel, Question1, Question2,
Question3, Question4, Question5, Question6, group1, group2, Question9,
Question10)
sql = "INSERT INTO VideoBlog
([Age],[Gender],[EducationLevel],[Question1],[Question2],[Question3],[Question4],[Question5],[Question6],[Question7],[Question8],[Question9],Question10])
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
RunQueryString sql, arParms
%>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>VIDEO BLOGGING SURVEY FORM</title>
</head>

<script language="JavaScript">
function DataValidation()
{
if(document.frmTest.T1.value=="")
{
alert("You must enter a value for age");
return false;
}

if(document.frmTest.D1.value=="")
{
alert("You must select a gender");
return false;
}

if(document.frmTest.T2.value=="")
{
alert("You must enter a value for educational level");
return false;
}

if(!document.frmTest.R1[0].checked &&
!document.frmTest.R1[1].checked)
{
alert("You must select a value for question 1");
return false;
}

if(!document.frmTest.R2[0].checked &&
!document.frmTest.R2[1].checked)
{
alert("You must select a value for question 2");
return false;
}

if(!document.frmTest.R3[0].checked &&
!document.frmTest.R3[1].checked)
{
alert("You must select a value for question 3");
return false;
}

if(!document.frmTest.R4[0].checked &&
!document.frmTest.R4[1].checked)
{
alert("You must select a value for question 4");
return false;
}

if(!document.frmTest.R5[0].checked &&
!document.frmTest.R5[1].checked)
{
alert("You must select a value for question 5");
return false;
}

if(!document.frmTest.R6[0].checked &&
!document.frmTest.R6[1].checked)
{
alert("You must select a value for question 6");
return false;
}

if(!document.frmTest.C1.checked && !document.frmTest.C2.checked &&
!document.frmTest.C3.checked && document.frmTest.T3.value.length==0)
{
alert("You must select/enter a value for question 7");
return false;
}

if(!document.frmTest.C4.checked && !document.frmTest.C5.checked &&
!document.frmTest.C6.checked && document.frmTest.T4.value.length==0)
{
alert("You must select/enter a value for question 8");
return false;
}

if(document.frmTest.S1.value.length==0)
{
alert("You must enter a value for question 9");
return false;
}

if(document.frmTest.S2.value.length==0)
{
alert("You must enter a value for question 10");
return false;
}

return true;
}
</script>

<body>
<center><b>VIDEO BLOGGING SURVEY FORM</b></center>
<br><br>
Just fill in all the details on the form and press submit:
<br><br>
<center>
<form name="frmTest" method="POST" action="survey.asp" ONSUBMIT="return
DataValidation();">
<table border="1" cellpadding="0" cellspacing="1"
style="border-collapse: collapse" bordercolor="#000000" width="76%"
id="AutoNumber1">
<tr>
<td width="22%">Age</td>
<td width="78%"><input type="text" name="T1" size="20"></td>
</tr>
<tr>
<td width="22%">Gender</td>
<td width="78%">
<select size="1" name="D1">
<option value=""></option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</td>
</tr>
<tr>
<td width="22%">Educational level</td>
<td width="78%"<input type="text" name="T2" size="20"></td>
</tr>
<tr>
<td width="22%">&nbsp;</td>
<td width="78%">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2">1. Do you know what is a video blog?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="36%"
id="AutoNumber2">
<tr>
<td width="50%">
<input type="radio" value="Yes" name="R1"Yes</td>
<td width="50%">
<input type="radio" name="R1" value="No"No</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">2. Have you made an attempt to build
your own video blog?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="36%"
id="AutoNumber2">
<tr>
<td width="50%">
<input type="radio" name="R2" value="Yes"Yes</td>
<td width="50%">
<input type="radio" name="R2" value="No"No</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">3. Which video blog do you visit the
most?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="36%"
id="AutoNumber2">
<tr>
<td width="50%">
<input type="radio" name="R3" value="Yes"Yes</td>
<td width="50%">
<input type="radio" name="R3" value="No"No</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">4. How often do you visit a video
blog?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="36%"
id="AutoNumber2">
<tr>
<td width="50%">
<input type="radio" name="R4" value="Yes"Yes</td>
<td width="50%">
<input type="radio" name="R4" value="Yes"No</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">5. Do you own a video recording tool?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="36%"
id="AutoNumber2">
<tr>
<td width="50%">
<input type="radio" name="R5" value="Yes"Yes</td>
<td width="50%">
<input type="radio" name="R5" value="No"No</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">6. What are you interested in?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="36%"
id="AutoNumber2">
<tr>
<td width="50%">
<input type="radio" name="R6" value="Yes"Yes</td>
<td width="50%">
<input type="radio" name="R6" value="No"No</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">7. Are you satisfied in using a video
blog?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#000000" width="59%"
id="AutoNumber2">
<tr>
<td width="33%">
<input type="checkbox" name="C1" value="Food"Food</td>
<td width="67%">
<input type="checkbox" name="C2" value="Books"Books</td>
</tr>
<tr>
<td width="33%">
<input type="checkbox" name="C3" value="Travel"Travel</td>
<td width="67%">
Others <input type="text" name="T3" size="20">
</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">8. Which feature do you prefer to use
in a "video blog"?
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FFFFFF" width="60%"
id="AutoNumber2">
<tr>
<td width="37%">
<input type="checkbox" name="C4" value="Search"Search</td>
<td width="63%">
<input type="checkbox" name="C5" value="Emailing">
Emailing</td>
</tr>
<tr>
<td width="37%">
<input type="checkbox" name="C6" value="Subscription">
Subscription</td>
<td width="63%">
Others <input type="text" name="T4" size="20">
</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">9. Why do you use a video blog?<br>
<textarea rows="6" name="S1" cols="36"></textarea>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2"><br>10. Comments:<br>
<textarea rows="6" name="S2" cols="36"></textarea>
<br>
</td>
</tr>
<tr>
<td width="100%" colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="100%" colspan="2">
<center>
<input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2">
</center>
</td>
</tr>
</table>
</form>
</center>
<br><br>
<center>Thank you for filling up the video blogging survey
form.</center>
</body>
</html>
The table is created using ms access and I am getting the following
error:

-2147217900:Syntax error in INSERT INTO statement.

How do I solve the problem?

Oct 2 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
solomon_13000 wrote:
<%
age = Trim(request.form("T1"))
<snip>
You need to validate these inputs here. Do not depend on client-side
validation working.

For now, just response.write each of these variables and confirm that
they contain what you expect them to contain. Show us their contents if
looking at them does not help you spot the problem.

>
arParms = Array(age, gender, educationlevel, Question1, Question2,
Question3, Question4, Question5, Question6, group1, group2, Question9,
Question10)
Better yet, loop through arParms and response.write its contents.
sql = "INSERT INTO VideoBlog
([Age],[Gender],[EducationLevel],[Question1],[Question2],[Question3],[Qu
estion4],[Question5],[Question6],[Question7],[Question8],[Question9],Que
stion10])
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
RunQueryString sql, arParms
%>
Response.write the sql variable as well. It looks correct to me, but I
can't really go by the vbscript code. Show us the statement that results
from the vbscript code.
None of the rest of this seems relevant, so:
<snip>
>
The table is created using ms access and I am getting the following
error:

-2147217900:Syntax error in INSERT INTO statement.

How do I solve the problem?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.