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

SELECT query with LIKE doesn't work in a program

P: 2
This is a peculiar problem for me. I am finding that the following query works perfectly and gives the expected result set when used in the Access query design environment, but it simply gives no results at all in an otherwise functioning C# web application program:

SELECT * FROM RR_Contacts WHERE FirstName LIKE '*Robert*'

While this query works (gives a result set) with either single or double quotes etc etc using Access to execute the query, but when used within my program, no results of any kind are returned from the same database under the same conditions at the same time (more or less).

I can't see the problem. Am I nuts or missing something simple? Note that all other queries and database functions work as expected. I just can't get the LIKE clause to work in my program. Waaah!

Budsy
Oct 16 '07 #1
Share this Question
Share on Google+
3 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi, Budsy.

Try different wildcard.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM RR_Contacts WHERE FirstName LIKE '%Robert%'
  2.  
Oct 16 '07 #2

P: 2
Well I'll be darned! The % wildcard worked. But I thought Access used the asterisk and not the % sign. Ah.... the variable in all this is that maybe the .NET Odbc stuff replaces the % with the * at run time. Or something.

Thanks for the tip!
Oct 17 '07 #3

FishVal
Expert 2.5K+
P: 2,653
Well I'll be darned! The % wildcard worked. But I thought Access used the asterisk and not the % sign. Ah.... the variable in all this is that maybe the .NET Odbc stuff replaces the % with the * at run time. Or something.

Thanks for the tip!
I quite agree with you. That seems to be dataprovider (Jet OLEDB ?) that accepts SQL expressions in ANSI92 standard not native for Access.

Good luck.
Oct 17 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.