473,387 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

-2147217900:Syntax error in INSERT INTO statement.

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
1 4994
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Gérard Leclercq | last post by:
ACCESS First fields are TEXT, last 2 are Numbers The name of the fields are correct. Dim MyConn Set MyConn=Server.CreateObject("ADODB.Connection") MyConn.Open...
4
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out...
3
by: William | last post by:
i am using a dataset and a DataAdapter to update a table with the following schema: ResourceID ProjectID LastName FirstName Year Nov Dec Jan
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
2
by: eric dugal | last post by:
Hi all!! I need your help.... i'm working since 2 hours on a simple insert statement, but couldn't handle it. Here is my code : public int ExecQuery(string SqlString) {
3
by: Neil Zanella | last post by:
Hello, I am trying to execute ADO.NET INSERT statement where one of the fields is coming from a password HTML control. When I access the text with password.Value and print with Response.Write...
3
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
2
by: RSH | last post by:
I have a rather simple script that transfers data from a SQL server database to an Access database. The procedure is intended to be dynamic so I am basically adding a datarow and then passing the...
6
by: ewpatton | last post by:
Good day, I've been trying to work with SQL and an Access database in order to handle custom user profiles. I haven't had any trouble reading from my database, but inserting new entries into...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.