LIKE query gives different results in Access 2000 and VB6 SP5 
Author Message
 LIKE query gives different results in Access 2000 and VB6 SP5

When I use the LIKE in a query in Access 2000, I get correct results.  When
I use the same query in VB, I get no results.

Example:  SELECT * FROM tblAbc WHERE fldName LIKE "son"  (I used the query
builder in Access 2000 then copied the SQL).

Results should produce: Richardson, Johnson, Mansoni, Masonville, Allison,
etc.  I tried the exact same query in both Access 2000 (success) and in VB6
SP5 (results is empty set).  All other queries work perfect, only when I use
LIKE, I get skewed results.  My intention is to find all records with a
particular subset of characters within one field.

Has anyone seen this unusual behaviour?  Hope to hear from someone soon.

Anny Mueller



Sun, 26 Dec 2004 11:29:13 GMT  
 LIKE query gives different results in Access 2000 and VB6 SP5
Try with SELECT ..................... LIKE "%son%"

Good luck

Jorge Hernandez



Quote:
> When I use the LIKE in a query in Access 2000, I get correct results.
When
> I use the same query in VB, I get no results.

> Example:  SELECT * FROM tblAbc WHERE fldName LIKE "son"  (I used the query
> builder in Access 2000 then copied the SQL).

> Results should produce: Richardson, Johnson, Mansoni, Masonville, Allison,
> etc.  I tried the exact same query in both Access 2000 (success) and in
VB6
> SP5 (results is empty set).  All other queries work perfect, only when I
use
> LIKE, I get skewed results.  My intention is to find all records with a
> particular subset of characters within one field.

> Has anyone seen this unusual behaviour?  Hope to hear from someone soon.

> Anny Mueller



Sun, 26 Dec 2004 15:10:43 GMT  
 LIKE query gives different results in Access 2000 and VB6 SP5

Quote:
> Try with SELECT ..................... LIKE "%son%"

> Good luck

> Jorge Hernandez

Not sure if its % or * in Access. Try both, one of them will work :-)
--
Allen

When Johnny comes marching home again
He's coming by bus or underground
A womans eye will shed a tear, To see his face so beaten in fear
It was just around the corner in the English Civil War



Sun, 26 Dec 2004 16:38:33 GMT  
 LIKE query gives different results in Access 2000 and VB6 SP5
* in Access
% in VB

Bye



Quote:


> > Try with SELECT ..................... LIKE "%son%"

> > Good luck

> > Jorge Hernandez

> Not sure if its % or * in Access. Try both, one of them will work :-)
> --
> Allen

> When Johnny comes marching home again
> He's coming by bus or underground
> A womans eye will shed a tear, To see his face so beaten in fear
> It was just around the corner in the English Civil War



Sun, 26 Dec 2004 23:51:14 GMT  
 LIKE query gives different results in Access 2000 and VB6 SP5
In VB, I believe, if you use DAO, it is *, if ADO, it is %.


Quote:
> * in Access
> % in VB

> Bye





> > > Try with SELECT ..................... LIKE "%son%"

> > > Good luck

> > > Jorge Hernandez

> > Not sure if its % or * in Access. Try both, one of them will work :-)
> > --
> > Allen

> > When Johnny comes marching home again
> > He's coming by bus or underground
> > A womans eye will shed a tear, To see his face so beaten in fear
> > It was just around the corner in the English Civil War



Mon, 27 Dec 2004 00:55:42 GMT  
 LIKE query gives different results in Access 2000 and VB6 SP5
in raw SQL I would use the following to get the results you desire

SELECT * FROM tblAbc WHERE fldName LIKE '%son%'

% is "anything" and note use of single quoutes. Beware of using % too much -
it can be very time consuming to the server on large DBs


Quote:
> When I use the LIKE in a query in Access 2000, I get correct results.
When
> I use the same query in VB, I get no results.

> Example:  SELECT * FROM tblAbc WHERE fldName LIKE "son"  (I used the query
> builder in Access 2000 then copied the SQL).

> Results should produce: Richardson, Johnson, Mansoni, Masonville, Allison,
> etc.  I tried the exact same query in both Access 2000 (success) and in
VB6
> SP5 (results is empty set).  All other queries work perfect, only when I
use
> LIKE, I get skewed results.  My intention is to find all records with a
> particular subset of characters within one field.

> Has anyone seen this unusual behaviour?  Hope to hear from someone soon.

> Anny Mueller



Mon, 27 Dec 2004 05:26:38 GMT  
 LIKE query gives different results in Access 2000 and VB6 SP5
Thank you to all who have answered.  Yes, very true.  With DAO use * and
with ADO user %.  I have written a universal query containing LIKE *son* OR
LIKE %son% which will work with both DAO and ADO.

I don't get it.  Why would MS programmers switch from the * to the %?

Thank you to all again.  Anny Mueller


Quote:
> In VB, I believe, if you use DAO, it is *, if ADO, it is %.



> > * in Access
> > % in VB

> > Bye





> > > > Try with SELECT ..................... LIKE "%son%"

> > > > Good luck

> > > > Jorge Hernandez

> > > Not sure if its % or * in Access. Try both, one of them will work :-)
> > > --
> > > Allen

> > > When Johnny comes marching home again
> > > He's coming by bus or underground
> > > A womans eye will shed a tear, To see his face so beaten in fear
> > > It was just around the corner in the English Civil War



Thu, 30 Dec 2004 22:55:11 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Different query results in Access 2000 than in VB

2. 97 gives different result to 2000

3. Ranking Search Results in VB6 to Access 2000 Query

4. VB6 With SP5 and Access 2000

5. VB6 with SP5 and Access 2000

6. Access 2000 MDB and VB6.0 SP5 and datagrid

7. VD and ACCESS give different results

8. ??? Result of a Query into different Access 2.0 database

9. HELP...Queries return different results in VB than Access

10. Warning about VB6 SP5 and Windows 2000

11. Install VB6 (SP5) program to Win 2000

12. MTS Reference VB6 sp5 in Win 2000 server HELP

 

 
Powered by phpBB® Forum Software