LIKE query gives different results in Access 2000 and VB6 SP5
Author |
Message |
Anny Muelle #1 / 7
|
 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 |
|
 |
Jorge HernĂ¡nde #2 / 7
|
 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 |
|
 |
Ats #3 / 7
|
 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 |
|
 |
Jorge HernĂ¡nde #4 / 7
|
 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 |
|
 |
Norman Yua #5 / 7
|
 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 |
|
 |
uncle wobbl #6 / 7
|
 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 |
|
 |
Anny Muelle #7 / 7
|
 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 |
|
|
|