Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

wildcard * don't work with sql query to mdb using ado

Posted on 2004-10-14
6
Medium Priority
?
313 Views
Last Modified: 2008-03-06
Hi, experts
 my code is
        cnDBF.Provider = "Microsoft.Jet.OLEDB.4.0"
       ' cnDBF.Properties("Extended Properties") = "dBase iv" commented now use .mdb
        cnDBF.Properties("Data Source") = Text1.Text
        cnDBF.CursorLocation = adUseClient
        cnDBF.Open
 
        sSQL = "SELECT * " & _
            "FROM kladr where mcode like '*000000';"
         Set rsRegion = New adodb.Recordset
        rsRegion.Open sSQL, cnDBF, adOpenDynamic, _
                       adLockBatchOptimistic, adCmdText

mcode is a string field and nothing records is selected, but the other wildcard
work true :
        sSQL = "SELECT * " & _
         "FROM kladr where code like '#####00000000';"
Can anybody help me/  

0
Comment
Question by:Eugeny
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
Z03niE earned 750 total points
ID: 12316456
My friend, use percent symbol(%) instead of wildcard.
Something like :

        sSQL = "SELECT * " & _
            "FROM kladr where mcode like '%000000';"
0
 
LVL 10

Expert Comment

by:anv
ID: 12317085
hi  Eugeny

actually  will work for SQL Server  Databases and % works for MS Access Databases...

so instead of * use %

as commented by Z03niE
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12318178
anv, are you sure?

(taken from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_la-lz_115x.asp)
%  -  Any string of zero or more characters. WHERE title LIKE '%computer%' finds all book titles with the word
        'computer' anywhere in the book title.

_   -  Any single character. WHERE au_fname LIKE '_ean' finds all four-letter first names that end with ean (Dean,
        Sean, and so on).

[ ]  - Any single character within the specified range ([a-f]) or set ([abcdef]). WHERE au_lname LIKE '[C-P]arsen'
        finds author last names ending with arsen and beginning with any single character between C and P, for
        example Carsen, Larsen, Karsen, and so on.

[^] - Any single character not within the specified range ([^a-f]) or set ([^abcdef]). WHERE au_lname
        LIKE 'de[^l]%' all author last names beginning with de and where the following letter is not l.

I was under the impression that, as Z03niE said, Eugeny should use '%'.

J
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12318191
anv:

My apologies; you did actually say to use '%'.

J.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question