Problem with SQL sentence for MS Access
Hi everyone,
I'm trying to execute a SQL command in VC++.
CString sSentence;
sSentence = "SELECT * FROM Client WHERE Name LIKE 'j*'";
rs.Open (CRecordset::forwardOnly, sSentence.c_str ());
So it must return the names in the Client table starting with 'j', but this function doesn't return a register. This sentence works fine in MS Access and it returns the names starting with 'j' correctly.
If I use
sSentence = "SELECT * FROM Client WHERE Name LIKE 'the_complete_name'";
rs.Open (CRecordset::forwardOnly, sSentence.c_str ());
it returns the registers involving that name.
I've read and searched this and other forums, but the solutions I found doesn't work.
Thanks in advance for the help.
[840 byte] By [
evth_sux] at [2007-11-20 11:32:31]

# 1 Re: Problem with SQL sentence for MS Access
Try:
"SELECT * FROM Client WHERE Name LIKE 'j%'"
I know that MS Access uses * instead of %... But I remember that this was how it works when using OLEDB... Anyway, you won't lose a lot if you try...
hspc at 2007-11-9 13:45:39 >

# 3 Re: Problem with SQL sentence for MS Access
Hi all.
I've met with this problem yet...
The '%' character is the standard SQL wildcard that takes the place of any substring in queries, but Access accepts '*' also.
In my opinion, when you perform the query within Access '*' is correct, but when the query is executed via ODBC (as probably yo're doing) then only the SQL standard wildcard '%' is right.