Creating a Connection Object : ADODB.Connection « Access « VBA / Excel / Access / Word

Creating a Connection Object

Sub CreateConnection()
    'Declare and instantiate the connection
    Dim cnn As ADODB.Connection
    Set cnn = New ADODB.Connection

    'Open the connection
    cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
    "Persist Security Info=False;" & _
    "User ID=Admin;" & _
    "Data Source=" & CurrentProject.Path & _

    Set cnn = Nothing
End Sub


Related examples in the same category

1.Connection to database
2.Connect to current database up a schema with a provider to look at all the database objects
4.Connect to databse through URL
5.The Errors Collection
6.Connect to database with user name and password