keith22
December 21st, 1999, 01:28 AM
how to write the code of viewing microsoft access database in visual basic?
can u pls help me out of this problem?
i wanna use the visual basic to view the data from the access database
thanks alot
smalig
December 21st, 1999, 02:44 AM
Goto Project-References. Add the Microsoft DAO 3.51 Object Library. And copy the follow code to your project.
Dim MyDB As Database, MySet As Recordset
' Open Database:
Set MyDB = OpenDatabase("d:\database.mdb")
'Create Recordset from query and load list with results:
Set MySet = MyDB.OpenRecordset("books") 'Open the Books table
MySet.MoveFirst
While MySet.EOF = False
Debug.Print MySet("name") 'Look the Name field
MySet.MoveNext
Wend
'Clean up - close objects:
MySet.Close
MyDB.Close
Set MySet = Nothing
Set MyDB = Nothing
smalig@hotmail.com
http://vbcode.webhostme.com/