The Connection Object

The Connection object is the highest level of the ADO object model. The Connection object allows you to establish a connection to a data source. You must declare a Connection object before you can use it, as shown here:

Dim cnConnection as ADODB.Connection

References - ChSCodeExamples w

Available References:

0 Visual Basic For Applications v Microsoft Access 11.0 Object Library v OLE Auiomation

Cancei

..¡Microsoft Access Wizard Control Library U Microsoft ActiveX Data Objects 2. 1 Library

□ Microsoft ADO Ext. 2.7 for DDL and Security U Microsoft DAO 3.6 Object Library

□ IAS Helper COM Component 1.0 Type Library ij IAS RADIUS Protocol 1.0 Type Library

□ Access 1.0 Type Library

□ Acrobat Distiller iirnin Upt 1.0 Tvnp i ihr^rv

Priority

Help

Microsoft ActiveX Data Objects 2.7 Library

Location: C:\prograrinFiles '..Common Files V5y stem '^do \nnsado 15. : Language: Standard

Figure 5.2

After declaring a Connection object, you must then instantiate a new Connection object, as follows:

Set cnConnection = New ADODB.Connection

Once instantiated, a Connection object can be opened to connect to Access and other databases. You open a connection by using the Open method of the Connection object. The Open method accepts various parameters, including a connection string, user id, password, and options.

0 0

Post a comment