|
-
Dec 14th, 1999, 07:05 AM
#1
Okay, this may sound ignorant, but I'm having a prob getting my VB project to recognize the Access database as where all SQL queries are to hit. Everything I've read in Help & Mastering VB 6.0 shows sample code of client side applications hitting a SQL DB on a server somewhere. My Access database is on the same computer where the VB project stays. How do I define this database (only one table) as the source for the one SQL query string in my code?
-
Dec 14th, 1999, 09:20 AM
#2
You can use DAO object library. Add a reference to Microsoft DAO library 3.51 (or select the highest version you have installed on your computer). Also, add a listbox to your form. Then you can use this code:
Code:
Dim db As Database
Dim rs As Recordset
Set db = Workspaces(0).OpenDatabase("C:\MyDB.mdb") 'Change this to appropriate path
Set rs = db.OpenRecordset("MyTable", dbopenTable)
Do Until rs.EOF
List1.AddItem rs("Name")
rs.MoveNext
Loop
Assuming that I have a table called MyTable and a field in that table called Name.
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 12-14-1999).]
-
Dec 14th, 1999, 11:29 PM
#3
Hyperactive Member
I don't know a whole lot about Access databases, but do they accept SQL statements? Or do they have their own set of codes? You might look into that.
------------------
Ryan
[email protected]
ICQ# 47799046
[This message has been edited by Gimpster (edited 12-15-1999).]
-
Dec 15th, 1999, 06:29 AM
#4
Frenzied Member
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
|