-
Aug 9th, 2005, 02:10 PM
#1
Thread Starter
New Member
Unable to pull information from access DB
I am trying to use an sql statement to retreive data from an access database using "Like" but it doesnt seem to be working. I have a field called LName which contains last names. I am trying to select all last names that begin with "A". I have verified that there are several names starting with "A" and the field and database names are correct. If I go into access and create a query and view that query it collects the data correctly. Also if I use the same code below without the Like it pulls in the entire database correctly.
SetNavButtons 3
Set conMyDB = New ADODB.Connection
Set rsCust = New ADODB.Recordset
conMyDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & _
"\phonebook.mdb"
conMyDB.Open
rsCust.Open "SELECT * FROM tblCust Where LName Like 'A*' Order By LName", conMyDB, adOpenDynamic, adLockOptimistic
PopFields
SetFields False
SetActionButtons 1
I also tried saving the query in access and calling it from VB with the same result. The result is Either EOF or BOF is true. basically it seems it is not pulling in any data.
The syntax I used to try and call the query is below. Either method will be fine. I just need to get one or the other to work.
'rsCust.Open "SELECT * FROM qryA", conMyDB, adOpenDynamic, adLockOptimistic
'rsCust.Open "qryA", conMyDB, adOpenDynamic, adLockOptimistic
Any help would be appreciated.
-
Aug 9th, 2005, 02:13 PM
#2
Re: Unable to pull information from access DB
When using SQL statement instend of using the asterick "*" is the percent sign "%" as the wildcard.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Aug 9th, 2005, 02:19 PM
#3
Thread Starter
New Member
Re: Unable to pull information from access DB
Bless you Bless you Bless you. I have been beating my head against this for hours trying everything I knew possible lol
Thank you for your help
-
Aug 9th, 2005, 02:28 PM
#4
Fanatic Member
Re: Unable to pull information from access DB
Here's a link to the microsoft page on wildcards.
Microsoft
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
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
|