Solved

Insert Into DB syntax issue

Posted on 2004-08-15
5
264 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

726 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