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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using Wildcard '*' from Visual basic 6.0 1

Status
Not open for further replies.

Danny012

Programmer
Jul 21, 2000
2
GB
I'm useing ACCESS 2000.<br>I'm tring to get a 'like' select statement(Select Name from Table where UserID like '0321*') from VB6 using ODBC, and It doesn't work.<br>I put the same select statement at access query form, and It works.<br>If I Use a 'like' select statement feel with '%' in the length of the variable, it works fine (select Name from Table where UserID like '0321%%%%%'), but it not a good way a program should look like...isn't it?!<br><br>Is there a bug in VB6 ODBC access to Miscrosof Access?!<br>
 
A couple of things.<br><br>MS SQL server uses &quot;%&quot; for the wildcard character and MS Access uses &quot;*&quot;<br>So with SQL as the data source this statement will work.<br>&quot;Select * from table where name like '%Jon'&quot;<br>...will find 'Johnson' , 'Jones', etc..<br><br>In MS Access, it looks like...<br>&quot;Select * from table where name like &quot;*Jon&quot;&quot;<br><br>But wait, there is another difference here! Do you see it ?<br><br>O.K. no time for games. Notice the quotation marks in the Jet query statement. You''ll have to embed quotation marks in the Jet Query statment to make it work.<br><br>Have fun.<br>&nbsp;<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
I have found this too. In testing it shows as a definite bug. In Jet I reckon.<br><br>the query <br><br>select field where field like 'a*'<br><br>runs in Access but the same query entered into the data manager will fail to produce results.<br><br>All other operators work fine but not like.<br><br>However, the like operator will work as a recordset filter statment. So retreive the data to an ADODB receordset and then set the filter property to your like statement. This works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top