Connecting to a Database File

First, you need to add a reference to the Microsoft ActiveX Data Objects library, as shown in Figure 19-2.

Vba Autocad Interface
Figure 19-2. Microsoft ActiveX Data Objects library reference

Next, you need to establish a Connection object similar to the following example: Dim oAccess As New ADODB.Connection oAccess.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=" & "C:\AutoCAD-VBA.mdb" & ";"

Note The example database for this exercise was created in Microsoft Access 2000. If you want to use a different file-format database, such as Access 97 or 2002, you'll need to change the Provider string appropriately or use an ODBC data source name (DSN) to provide the interface connection directives.

Was this article helpful?

0 0

Post a comment