|
-
June 6th, 2008, 01:25 PM
#1
cannot use * in ado record sets
I have a program that looks up data in an access database using an ado recordset in visual studio 2005. my problem is that i wanted to be able to enter something into a text box and select only records that CONTAIN what ever is in the text box. i've tried the following:
"select * from myQuery where (field like *'" & textBox.text & "'*);"
which works with an access query but when i've used the exact same statement in a recordset.open command it doesn't find any records. does anyone know why this is happening or another way of searching records?
-
June 6th, 2008, 01:36 PM
#2
Re: cannot use * in ado record sets
Been ages since I've messed around with access, but shouldn't the ' be on the other side of the *?
Like this:
Code:
"select * from myQuery where (field like '*" & textBox.text & "*');"
-
June 6th, 2008, 04:57 PM
#3
Re: cannot use * in ado record sets
johntheface,
In addition to Alsvha's comment, I thought ADO's wildcard character was %, not *.
Kerry Moorman
-
June 6th, 2008, 05:58 PM
#4
Re: cannot use * in ado record sets
 Originally Posted by kmoorman
johntheface,
In addition to Alsvha's comment, I thought ADO's wildcard character was %, not *.
Kerry Moorman
For MS-Access databases % sign does not work. You will have to use * as shown in Post # 2.
-
June 6th, 2008, 07:18 PM
#5
Re: cannot use * in ado record sets
this is correct:
Code:
"select * from myQuery where field like '" & textBox.text & "*'"
no * before the like field, but afterwords. For phone numbers, I've found that we had to use % before. YMMV
-
June 7th, 2008, 05:10 AM
#6
Re: cannot use * in ado record sets
 Originally Posted by Shuja Ali
For MS-Access databases % sign does not work. You will have to use * as shown in Post # 2.
Not sure I understand or agree ( although I'm not a boffin on databases )
In a recent project, using MS Access, I had to use the % indicating the remaining characters.
I did this :
Code:
PlaySearch = "SELECT * FROM " & pclListPT.PCLRetStr '& " WHERE " & _
PlayFieldStr & " LIKE '" & abPConditions.Text & "%' "
When I entered a value such as Met in the abPConditions TextBox, it returned all values starting with Met. So, If I used the Artist field ( pclListPT.PCLRetStr ) , it returns me all Metallica records.
It works for me
Last edited by HanneSThEGreaT; June 7th, 2008 at 05:15 AM.
-
June 7th, 2008, 12:52 PM
#7
Re: cannot use * in ado record sets
 Originally Posted by HanneSThEGreaT
Not sure I understand or agree ( although I'm not a boffin on databases )
In a recent project, using MS Access, I had to use the % indicating the remaining characters.
I stand corrected. 
I have not touched MS-Access since past 4 years now. I remember using * as a wild card, but that might have changed now.
-
June 10th, 2008, 09:22 AM
#8
Re: cannot use * in ado record sets
As I recall, you use % in ADO(.NET) queroes, but * within Access (as a front end to Jet) for wildcard
-
June 10th, 2008, 12:21 PM
#9
Re: cannot use * in ado record sets
If you prepare a query in MS Access you must use * char..
but if you connect database with Ado, you must use % char...
I have used % char in many projects..
-
June 10th, 2008, 03:47 PM
#10
Re: cannot use * in ado record sets
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
|