|
-
Jul 5th, 2000, 07:39 PM
#1
Thread Starter
Member
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.
-
Jul 5th, 2000, 08:32 PM
#2
Addicted Member
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.
-
Jul 5th, 2000, 08:37 PM
#3
Thread Starter
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
|