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

D

devprog

objConn = New ADODB.Connection
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data 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)
 
D

Doug Bell

Try enclosing Date and Time inside Square Brackets [Date], [Time] as they
are reserved words.

Doug
 
D

devprog

Hi Bell,

Thanks so much for the helping.

Doug Bell said:
Try enclosing Date and Time inside Square Brackets [Date], [Time] as they
are reserved words.

Doug
devprog said:
objConn = New ADODB.Connection
objConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data 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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top