views:

29

answers:

1

Odd one this...

The following command returns what I would expect when I run it in query window in Access 2003:

SELECT * FROM Train WHERE [Days] LIKE '*3*'

However when I pass this into my C# code to run (returning an OleDbDataReader) I get nothing.I suspect it's something to do with the LIKE command (when I remove this I get rows).

Any thoughts?

+1  A: 

Just a guess but try this:

SELECT * FROM Train WHERE [Days] LIKE '%3%'
Sjuul Janssen
This is correct: the sql dialect used via Access' query builder and that used by the oledb connection are not the same. The biggest difference is in the wild cards used, but if you are building complex queries you sometimes find some other issues as well.
mavnn
doh! thanks Sjuul
Jim
I expected it to be in the line of what mavnn said but I couldn't back it up like him ;)
Sjuul Janssen
Within Access, the legacy "SQL 89" mode is used, with * and ? wildcards, likewise if accessing the data via DAO. If you turn on "SQL 92" mode in Access, it will use % and _, which is also what you should use if you're using ADO/OLEDB.
David-W-Fenton