|
-
Sep 12th, 2000, 09:46 AM
#1
Urrrgh!!! Am soooo annoyed! OK...figure this one out if you can...
I've got an Access 2000 database called "Phone Book.mdb" in the same directory as my program.
The database contains a table called "People" with the fields "ID", "Name" and "Notes".
There is currently 1 record in the table:
Code:
ID Name Notes
1 Matthew Ralston
If I run the following query
Code:
SELECT ID, Name FROM People WHERE Name LIKE 'm*'
in Access it works fine and returns 1 record. However if I run it in VB using ADO 2.1 it returns 0 records:
Code:
Dim oConn As New ADODB.Connection, oRS As New ADODB.Recordset
oConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=Phone Book.mdb"
oConn.Open
oRS.Open "SELECT ID, Name FROM People WHERE Name LIKE '" & "m" & "*'", oConn
oRS.MoveFirst
Debug.Print oRS("Name")
oRS.Close
oConn.Close
Note that this is a simplified version of the code...the real one runs inside a loop and puts all records returned into a treeview control. I have tested the above code and the same problem occurs.
Any ideas why?
[Edited by matthewralston on 09-12-2000 at 10:48 AM]
-
Sep 12th, 2000, 10:39 AM
#2
Lively Member
ADO vs DAO
ADO uses
Code:
SELECT ID, Name FROM People WHERE Name LIKE 'm%'
and DAO uses
Code:
SELECT ID, Name FROM People WHERE Name LIKE 'm*'
See the diffrence, % for ADO and * for DAO
Yesterday, all my troubles seemed so far away...
Help, I need somebody, Help...
Now MCSD and still locking for intresting job in the south parts of Stockholm, Sweden.
-
Sep 12th, 2000, 10:46 AM
#3
Ooooh!!!!! My hero!!!! Thank you! Thank you! Thank you!
Geez how idiotic is that?
Am gonna shoot Bill G when I see him next!!!
Well...at least it works now! Ta. It was drivin me up the wall. 
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
|