M
Mike
I am having trouble writing date fields into an Access dbase.
My code is as follows:
<% if request.form("isSubmitted") = "yes" then %>
<%
DIM Conn,strConn,SQLstmt,RS
set Conn = server.createobject("adodb.connection")
strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("database.mdb")
Conn.open strConn
SQLstmt = "INSERT INTO TestTable (CurDate,CurDateTime)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "#" & CurDate & "#,"
SQLstmt = SQLstmt & "#" & CurDateTime & "#"
SQLstmt = SQLstmt & ")"
Set RS = conn.execute(SQLstmt)
My database data type is set to Date/Time with CurDate = Short Date and
CurDateTime = General Date.
When I submit this I get the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in
INSERT INTO statement.
date.asp, line 50
It was advised to me that I needed to put "#" as the seperator for the field
instead of "'".
(Example: SQLstmt = SQLstmt & "#" & CurDate & "#," NOT SQLstmt =
SQLstmt & "'" & CurDate & "'," )
I can not get it to work either way!
Any help is appreceiated,
Mikeal
My code is as follows:
<% if request.form("isSubmitted") = "yes" then %>
<%
DIM Conn,strConn,SQLstmt,RS
set Conn = server.createobject("adodb.connection")
strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("database.mdb")
Conn.open strConn
SQLstmt = "INSERT INTO TestTable (CurDate,CurDateTime)"
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "#" & CurDate & "#,"
SQLstmt = SQLstmt & "#" & CurDateTime & "#"
SQLstmt = SQLstmt & ")"
Set RS = conn.execute(SQLstmt)
My database data type is set to Date/Time with CurDate = Short Date and
CurDateTime = General Date.
When I submit this I get the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error in
INSERT INTO statement.
date.asp, line 50
It was advised to me that I needed to put "#" as the seperator for the field
instead of "'".
(Example: SQLstmt = SQLstmt & "#" & CurDate & "#," NOT SQLstmt =
SQLstmt & "'" & CurDate & "'," )
I can not get it to work either way!
Any help is appreceiated,
Mikeal