Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-10-14
6
Medium Priority
?
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

688 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