473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Wild Card in ADO

Have been trying to convert recordsets from DAO to ADO.

Program worked fine in DAO but am having trouble using wildcard in SQL string
for ADO recordset.

The problem is in the "Where" clause. Here are the two versions:
XXXXXXXXXXXXXXXXXXXXXXXXX

DAO version:

Dim Db as Database
Dim LN As String
Dim strSQL As String
Dim rst As Recordset

Set db = CurrentDb

strSQL = "SELECT [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "*"" )); "

Set rst = db.OpenRecordset(strSQL)

This works great in DAO.

ADO version:

Dim LN As String
Dim strSQL As String
Dim rst As New ADODB.Recordset

strSQL = "SELECT [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME] " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "%"" )); "

rst.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

This does not work in ADO

XXXXXXXXXXXXXXXXXXXXXXXXXXX

I have tried many versions of the syntax in the "Where" clause but can't seem
to get the wildcard to work properly in the ADO version. Note the change fro
"*" to
%" for the wildcard but that does not work either.

Any suggestions?

Thank you for the help.

Nov 12 '05 #1
2 4234
mf***@aol.com (MFS 43) wrote in
news:20***************************@mb-m28.aol.com:
Have been trying to convert recordsets from DAO to ADO.

Program worked fine in DAO but am having trouble using wildcard in SQL
string for ADO recordset.

The problem is in the "Where" clause. Here are the two versions:
XXXXXXXXXXXXXXXXXXXXXXXXX

DAO version:

Dim Db as Database
Dim LN As String
Dim strSQL As String
Dim rst As Recordset

Set db = CurrentDb

strSQL = "SELECT [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "*"" )); "

Set rst = db.OpenRecordset(strSQL)

This works great in DAO.

ADO version:

Dim LN As String
Dim strSQL As String
Dim rst As New ADODB.Recordset

strSQL = "SELECT [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME] " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "%"" )); "

rst.Open strSQL, CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

This does not work in ADO

XXXXXXXXXXXXXXXXXXXXXXXXXXX

I have tried many versions of the syntax in the "Where" clause but can't
seem to get the wildcard to work properly in the ADO version. Note the
change fro "*" to
%" for the wildcard but that does not work either.

Any suggestions?

Thank you for the help.


Are you connecting to SQL Server? If so try using single quotes for your
string delimiters.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2
Try

....
& "WHERE ((([PatientDemographics].[LASTNAME]) Like '" & LN & "%"' )); "

i.e. single quotes instead of the embedded double quotes.
--
Terry Kreft
MVP Microsoft Access
"MFS 43" <mf***@aol.com> wrote in message
news:20***************************@mb-m28.aol.com...
Have been trying to convert recordsets from DAO to ADO.

Program worked fine in DAO but am having trouble using wildcard in SQL string for ADO recordset.

The problem is in the "Where" clause. Here are the two versions:
XXXXXXXXXXXXXXXXXXXXXXXXX

DAO version:

Dim Db as Database
Dim LN As String
Dim strSQL As String
Dim rst As Recordset

Set db = CurrentDb

strSQL = "SELECT [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "*"" )); "

Set rst = db.OpenRecordset(strSQL)

This works great in DAO.

ADO version:

Dim LN As String
Dim strSQL As String
Dim rst As New ADODB.Recordset

strSQL = "SELECT [PatientDemographics].[LASTNAME],
[PatientDemographics].[FIRSTNAME] " _
& "FROM [PatientDemographics] " _
& "WHERE ((([PatientDemographics].[LASTNAME]) Like """ & LN & "%"" )); "

rst.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
This does not work in ADO

XXXXXXXXXXXXXXXXXXXXXXXXXXX

I have tried many versions of the syntax in the "Where" clause but can't seem to get the wildcard to work properly in the ADO version. Note the change fro "*" to
%" for the wildcard but that does not work either.

Any suggestions?

Thank you for the help.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gerry Viator | last post by:
Hi all, I want to remove the test after a period? Why does the wild card * not work? Dim test As String = "This is just a test report. ERCP" MessageBox.Show(Replace(test, ".*", "."))
1
by: Steve T | last post by:
I have just contracted with a firm that is using a front-end web interface to access our sales data. They developed it with Microsoft Dotnet, and it uses Microsoft SQL as the database. When I...
1
by: Tempy | last post by:
Could somebody please tell me if it is possible and if how? I am wanting to do : Iif(="*PE","Y","N") In other word i want it to fine HZPE, AEPE, HEPE etc... Les Stout *** Sent via Devdex...
1
by: =?Utf-8?B?S3Jpc3RpbmUgdGhlIERyYWdvbkxhZHk=?= | last post by:
Can anyone advise re spam emails which come through with the word V***gra (where the * are varying letters) - how do I specify the word just as I've typed the word with the asterisks? I can't find...
0
by: fullmetal87 | last post by:
Hi guys, I am having this problem I want to do a search with wild card e.g. ABC will retrieve all the group XYZABC123 or SKDABC or ABC234KD do anyone know the wildcard character to search??...
2
by: psbasha | last post by:
Hi, How to get a File Wild Card using Tkinter Module?. Could anybody has used this option.If so, the smaple snippet of the code will really help me. Thanks PSB
0
by: shamaila | last post by:
wild card characters are used to match strings as select * from table where name LIKE '%brown%'; but doesnt supports matching of dates,number what will we do if we want approximate matching of...
0
by: jmelasic1 | last post by:
I am working on a form now that has two things in it: a text box and a subform. The subform is from a query. The text box is just a normal text box. However, I would like to link the text box to...
3
rcollins
by: rcollins | last post by:
Here is the criteria I am using for my report... (Permissions.Path)=!!) On the criteria form, if I pick R:\Acct\ from the list, I get just those values. I would like to get more, like...
7
by: W. eWatson | last post by:
Is it possible to do a search for a wild card string in another string. For example, I'd like to find "v*.dat" in a string called bingo. v must be matched against only the first character in bingo,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.