Solved

Insert Into DB syntax issue

Posted on 2004-08-15
5
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

717 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