Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dummynewbie
Starting Member
4 Posts |
Posted - 2007-04-06 : 04:33:23
|
I'm a newbie and I'm trying to insert data through ODBC in a Microsoft Access Database. The idea is to preserve compatibility with any database, and I activated compatibility with ANSI 92. When I insert a date so:INSERT INTO Table1(TestDateTime) VALUES('28-02-2007 15:38:40');it works, but when I do a query like that:SELECT TestKey FROM Table1 WHERE TestDateTime='28-02-2007 15:38:40';it says "Data type mismatch in criteria expression". If I change the wildcard "'" to "#", it works, but it should be compatible with ANSI 92, and the INSERT works correctly with "'". I tries saving the database both in 2000 and 2002 format. Thanks for your help,dummynewbie |
|
dummynewbie
Starting Member
4 Posts |
Posted - 2007-04-06 : 04:39:47
|
A little error in my post, the dates I put in the database are written like that: '2007-02-28 15:38:40'. |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-04-06 : 11:32:05
|
The # is not a wildcard, it is the delimitter that Access uses for dates. So always enclose literal dates in #s. It may work sometimes if you enclose a date in quotes but if so then it is treating the date as a string first and converting it, so rather always use #s. |
 |
|
|
|
|