CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 1999
    Location
    MALAYSIA
    Posts
    5

    view access database in visual basic

    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


  2. #2
    Join Date
    Sep 1999
    Location
    Germany
    Posts
    66

    Re: view access database in visual basic

    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

    [email protected]
    http://vbcode.webhostme.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured