Solved

Insert Into DB syntax issue

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
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 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 update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now