Results 1 to 3 of 3

Thread: ADO with ACCESS databases

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    63
    Does anyone have a simple example to connect to an access database using ADO. I know I can connect using a connection object or connect via the recordset object. I'd prefer the later. I've done it in SQL/SERVER just haven't used ACCESS that much.


  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170
    Option Explicit

    'Declaration of ADO Database objects
    Private cnDBase As New ADODB.Connection 'Access 2000 Connection Object
    Private rsAccount As ADODB.Recordset 'Access 2000 Recordset Object

    'Database location and provider
    Private Const m_sProvider = "Microsoft.Jet.OLEDB.4.0;"
    Private Const m_sDataSource = "C:\Mydatabase.mdb"
    Private Const m_sAccountConnect = "Select * From Account"

    Private Sub Initialize()

    cnDBase.Provider = m_sProvider 'Database Provider
    cnDBase.ConnectionString = m_sDataSource 'Database Location
    cnDBase.Open 'Open the connection

    Set rsAccount = New ADODB.Recordset 'Create Instance
    Set rsTransactions = New ADODB.Recordset 'Create Instance

    rsAccount.CursorLocation = adUseClient 'Account cursor on client
    rsAccount.CursorType = adOpenStatic 'Cursor movement is Static
    rsAccount.LockType = adLockOptimistic 'Alows Addnew and Update

    rsAccount.Open m_sAccountConnect & sAccount, cnDBase 'Creates the Account RecordSet


    End Sub


    now rsAccount holds a recordset consisting of all records in rsAccount.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    63
    Thank you!

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