472,976 Members | 1,434 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,976 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 4962
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.