Solved

Insert Into DB syntax issue

Posted on 2004-08-15
5
258 Views
Last Modified: 2013-12-24
Here is my code, and it gives me a syntax error.  D1-D31 are dates, USERID is a session variable assigned to UID, R1-R31 is a string, as is N1-N31

<%
UID = Session("USERID")
Set Conn = Server.CreateObject("ADODB.Command")
 
 Conn.ActiveConnection= "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("/data/Time.mdb") &";DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5"
 Conn.CommandType =1


Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"',,#'"&Request.Form("D1")&"'#,'"&Request.Form("R1")&"','"&Request.Form("N1")&"');"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D2")&"','"&Request.Form("R2")&"','"&Request.Form("N2")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D3")&"','"&Request.Form("R3")&"','"&Request.Form("N3")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D4")&"','"&Request.Form("R4")&"','"&Request.Form("N4")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D5")&"','"&Request.Form("R5")&"','"&Request.Form("N5")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D6")&"','"&Request.Form("R6")&"','"&Request.Form("N6")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D7")&"','"&Request.Form("R7")&"','"&Request.Form("N7")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D8")&"','"&Request.Form("R8")&"','"&Request.Form("N8")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D9")&"','"&Request.Form("R9")&"','"&Request.Form("N9")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D10")&"','"&Request.Form("R10")&"','"&Request.Form("N10")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D11")&"','"&Request.Form("R11")&"','"&Request.Form("N11")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D12")&"','"&Request.Form("R12")&"','"&Request.Form("N12")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D13")&"','"&Request.Form("R13")&"','"&Request.Form("N13")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D14")&"','"&Request.Form("R14")&"','"&Request.Form("N14")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D15")&"','"&Request.Form("R15")&"','"&Request.Form("N15")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D16")&"','"&Request.Form("R16")&"','"&Request.Form("N16")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D17")&"','"&Request.Form("R17")&"','"&Request.Form("N17")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D18")&"','"&Request.Form("R18")&"','"&Request.Form("N18")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D19")&"','"&Request.Form("R19")&"','"&Request.Form("N19")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D20")&"','"&Request.Form("R20")&"','"&Request.Form("N20")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D21")&"','"&Request.Form("R21")&"','"&Request.Form("N21")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D22")&"','"&Request.Form("R22")&"','"&Request.Form("N22")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D23")&"','"&Request.Form("R23")&"','"&Request.Form("N23")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D24")&"','"&Request.Form("R24")&"','"&Request.Form("N24")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D25")&"','"&Request.Form("R25")&"','"&Request.Form("N25")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D26")&"','"&Request.Form("R26")&"','"&Request.Form("N26")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D27")&"','"&Request.Form("R27")&"','"&Request.Form("N27")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D28")&"','"&Request.Form("R28")&"','"&Request.Form("N28")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D29")&"','"&Request.Form("R29")&"','"&Request.Form("N29")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D30")&"','"&Request.Form("R30")&"','"&Request.Form("N30")&"')"
Conn.execute
Conn.CommandText = "INSERT INTO tblreq (USERID,Dater,Request,Comment) VALUES('"&UID&"','"&Request.Form("D31")&"','"&Request.Form("R31")&"','"&Request.Form("N31")&"')"
Conn.execute

Response.Redirect "TimeConf2.asp"

%>

Any help would be appreciated
0
Comment
Question by:toverholt
  • 3
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
rcmb earned 500 total points
ID: 11804077
First thing we need to fix is the Dates insertion -- you have #'"&Request.Form("D1")&"'#,

and it should read

#"&Request.Form("D1")&"#,

Note the # symbol replaces the '

On the first line of the insert you have

"&UID&"',,#'"&Request.Form("D1")&"'#,

Delete one of the commas after &UID&

Now -- if UID is an interger in the database then your insert should read

"&UID&" without the ' (single quote)

For all of your dates make the change I indicated above --  #"&request.form("DX")&"#

I would also place a space after the word VALUES

RCMB
0
 

Author Comment

by:toverholt
ID: 11804718
It still gives me the internal server error....  I think it must be caused by something else.
0
 

Author Comment

by:toverholt
ID: 11804741
OK, here is the poop!

When I data enter on the referring form, and click submit, I get the IE Internal Server Error, when I click refresh, I get my page theme with this error...

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression '##'.

/Time/TimeConfirm.asp, line 38


Any ideas?

Troy
0
 

Author Comment

by:toverholt
ID: 11804793
Ugh, I am so dopey!  It was the redirect command causing the trouble!  Thanks for the help!
0
 
LVL 12

Expert Comment

by:rcmb
ID: 11805082
Glad tohelp.

:=)

RCMB
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Web Designer 5 176
Serif Plus workable? 4 46
What script is Findcars.com using or where can I find a script that is similar? 6 86
I starting with php 12 133
Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question