error on insert (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


chadb -> error on insert (2/28/2008 9:20:00)

I am sure I am overlooking the obvious, but I am getting this error:

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

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

/updated.asp, line 11


using:


Dim myDSN
myDSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("fpdb\maplandates.mdb")

set MyConn=server.createobject("adodb.connection")
MyConn.open myDSN

sql = "INSERT INTO Calendar (date,event)"
sql = sql & "VALUES ('" & (Request.Form("date")) & "'," & "'" & (Request.Form("event")) & "')"
MyConn.execute(sql)






rdouglass -> RE: error on insert (2/28/2008 10:45:09)

quote:

sql = "INSERT INTO Calendar (date,event)"
sql = sql & "VALUES ('" & (Request.Form("date")) & "'," & "'" & (Request.Form("event")) & "')"


If that is a Date/Time field in the DB, try it this way:

sql = "INSERT INTO Calendar ([date],event)"
sql = sql & "VALUES (#" & (Request.Form("date")) & "#, '" & (Request.Form("event")) & "')"

1. "date" is a reserved word so you need to surround it with square brackets when using it as a field name.
2. Date/time fields in Access use a # for a delimiter instead of the apostrophe.

That help any?




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.03125