By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,977 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,977 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.