Results 1 to 2 of 2

Thread: Using Access database

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 1999
    Posts
    3

    Post

    Anyone know how to use access queries from visual basic using code. Any information on using code and access database is welcome. How to lock a db, etc.

  2. #2
    New Member
    Join Date
    Aug 1999
    Location
    Bombay,India
    Posts
    10

    Post

    Add a reference to DAO 3.51 object library from the project menu.

    Then write the foll. routine in your project

    Sub InitDB()

    Dim WS as Workspace
    Dim DB as Database
    Dim RS as Recordset

    Set WS = DBEngine.Workspaces(0)
    Set DB = WS.Opendatabase("C:\MyData.mdb")

    Set RS=DB.OpenRecordset("Select * from Employee where EmpNo = 10")

    With RS
    Text1= .fields("EmpNo")
    Text2= .fields("EmpName")
    Text3= .fields("Address")
    Text4= .fields("Phone")

    End With

    End Sub


    Add 4 text boxes and call initdb in your form load event after filling the database with some values

    To add values in the database use .Addnew and .Update


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