|
-
Dec 4th, 2000, 01:30 AM
#1
Thread Starter
New Member
I am switching from DAO to ADO in the next version of my application. The variable strSearch used to work fine with DAO but doesn't want to work in ADO. It uses an SQL LIKE clause.
The strSearch variable value is the result of user input in an input box:
strSearch = InputBox("Type name (or partial) to look for:", "Name")
The recordset is based on an SQL query:
"SELECT Name, Number FROM Patient WHERE Name Like '*" & strSearch & "*'"
The ADO code to open the recordset is as follows:
rstName.Open strSearch, cnnAccident, adOpenDynamic, adLockOptimistic
The DAO code I use to use is
Set rstName = dbsAccident.OpenRecordset(strSearch,dbOpenDyanaset)
Any help is appreciated.
ML
-
Dec 4th, 2000, 04:45 AM
#2
Hyperactive Member
what's happening? are you getting errors or is it just not returning any data?
-
Dec 4th, 2000, 05:03 AM
#3
Member
Try using % as the wild card instead of *
Ian
-
Dec 4th, 2000, 05:05 AM
#4
Fanatic Member
If that code really is what you are doing I am amazed it ever worked. Are you passing strSearch as an updated SQL string or as the result of the InputBox?
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Dec 4th, 2000, 11:10 AM
#5
Thread Starter
New Member
Thanks all for your prompt replies.
Good point Paul, I guess I didn't make it obvious in the open method, I passed the SQL string. I have since changed the variable.
Bigley, it wasn't returning any data.
Ian, I got the same advice as you provided from an online user last night and was able to fix my problem. I was under the (mis)understanding that the % wildcard was to be used only if you are connecting to an SQL Server database.
Thanks again.
Mary Lou
-
Dec 4th, 2000, 01:58 PM
#6
Member
Hi,
Yes i think you misunderstand the usage of wildcards
"*" can be used in Jet Engines, but not in ODBC/OLE DB Providers,so
Be sure that you have right connection string to your database if you use ODBC than even if you use databases other than SQL Server it won't work.So;
use % and _ for wildcards
Good Luck
World is hard to live but the only reason is inequality between the lives...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|