Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query in VB6

Status
Not open for further replies.

jrlbw

Programmer
Jun 27, 2002
15
US
I am having a problem setting up a SQL Query using the "Like" operator.
I need to retrieve a list of rows from an access db using a search for a word in the subject column in the db.

I set up the query as.....

select field1,field2,field3,subject from table where subject like '*data*' order by date

i know there are rows in the table with this data, but it returns 0 rows...

i copy the sql in an access query and it returns all the rows.....
any help???
thanks
 
Wild card character in SQL is %
Wild card in Access is *

Just change * to % and it will work! Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Can you maybe post some of the code containing the call to the database?
 
yes,,,,it works...
I was using a current vb6 database book and it stated "be sure to use the * instead of % when using access databases....sql server and most other databases use the %....

evidently the book was wrong...
thanks for the help...
 

The book was probably right to a certain extent.
Did the book use DAO or ADO?
Did the book refer to the rs.Open method or the FindFirst or the Filter methods? [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
the book in this particular chapter was using DAO...and the rs.open method...
 

Then the book was right....DAO/Jet uses an asterisk.... [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top