471,305 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

Access Insert - Syntax Error for field "DATE" but not for "DATE1"

objConn = New ADODB.Connection
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source=" & dbPath _
& ";Jet OLEDB:Database Password=" & dbPassword)

This cause error: (VB.NET. )

sqlString = "insert into table1 " _
& "(Date1,Time,Ext,Co) values " _
& "('04/04/05','06:02PM','101','01');"

But below is fine

sqlString = "insert into table1 " _
& "(Date1,'Time1,Ext,Co) values " _
& "('04/04/05','06:02PM','101','01');"
That is , if I change the Access Table filed name
from "Date" -> Date1
"Time" -> "Time1". Then the above code run through fine.
But in my VB6 code before, I used the same TABLE Field Name and it works.
(That was a different VB project, of course)

Nov 21 '05 #1
2 4378
Try enclosing Date and Time inside Square Brackets [Date], [Time] as they
are reserved words.

Doug
"devprog" <de*****@nospam.nospam> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
objConn = New ADODB.Connection
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source=" & dbPath _
& ";Jet OLEDB:Database Password=" & dbPassword)

This cause error: (VB.NET. )

sqlString = "insert into table1 " _
& "(Date1,Time,Ext,Co) values " _
& "('04/04/05','06:02PM','101','01');"

But below is fine

sqlString = "insert into table1 " _
& "(Date1,'Time1,Ext,Co) values " _
& "('04/04/05','06:02PM','101','01');"
That is , if I change the Access Table filed name
from "Date" -> Date1
"Time" -> "Time1". Then the above code run through fine.
But in my VB6 code before, I used the same TABLE Field Name and it works.
(That was a different VB project, of course)

Nov 21 '05 #2
Hi Bell,

Thanks so much for the helping.

"Doug Bell" <du*@bigpond.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
Try enclosing Date and Time inside Square Brackets [Date], [Time] as they
are reserved words.

Doug
"devprog" <de*****@nospam.nospam> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
objConn = New ADODB.Connection
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Dat a Source=" & dbPath _
& ";Jet OLEDB:Database Password=" & dbPassword)

This cause error: (VB.NET. )

sqlString = "insert into table1 " _
& "(Date1,Time,Ext,Co) values " _
& "('04/04/05','06:02PM','101','01');"

But below is fine

sqlString = "insert into table1 " _
& "(Date1,'Time1,Ext,Co) values " _
& "('04/04/05','06:02PM','101','01');"
That is , if I change the Access Table filed name
from "Date" -> Date1
"Time" -> "Time1". Then the above code run through fine.
But in my VB6 code before, I used the same TABLE Field Name and it works. (That was a different VB project, of course)


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.