Solved

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

Posted on 2004-10-14
6
300 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal reports - Formula Field code need assistance with code 17 52
Spell Check in VB6 13 99
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 47
VB6 ListBox Question 4 34
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now