?
Solved

Insert Into DB syntax issue

Posted on 2004-08-15
5
Medium Priority
?
274 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 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

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…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

770 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