ADO Connection object
ADO Connection object
Connection object
The ADO Connection object is used to create an open connection to a data source. Through this connection, you can access and operate on a database.
If you need to access a database multiple times, you should use the Connection object to establish a connection. You can also pass a connection string through a Command or Recordset object to create a connection. However, such connections are only suitable for a single, simple query.
ProgID
set objConnection=Server.CreateObject("ADODB.connection")
Property
| Attributes | Description |
|---|---|
| Attributes | Sets or returns the properties of the Connection object. |
| CommandTimeout | Indicates the time to wait during command execution before terminating the attempt and generating an error. |
| ConnectionString | Sets or returns the details used to establish the connection data source. |
| ConnectionTimeout | The time to wait for a connection to be established before a termination attempt is made and an error is generated. |
| CursorLocation | Sets or returns the location of the cursor service. |
| DefaultDatabase | Specifies the default database for the Connection object. |
| IsolationLevel | Specifies the isolation level for the Connection object. |
| Mode | Sets or returns the access permissions of the provider. |
| Provider | Sets or returns the name of the Connection object provider. |
| State | Returns a value describing whether the connection is open or closed. |
| Version | Returns the version number of the ADO. |
Method
| Method | Description |
|---|---|
| BeginTrans | Starts a new transaction. |
| Cancel | Cancels an execution. |
| Close | Close a connection. |
| CommitTrans | Save any changes and end the current transaction. |
| Execute | Execute a query, SQL statement, stored procedure, or provider specific text. |
| Open | Open a connection. |
| OpenSchema | Returns the schema information of the data source from the provider. |
| RollbackTrans | Cancels any changes made in the current transaction and ends the transaction. |
Event
**Note:** You cannot use VBScript or JScript to handle events (only Visual Basic, Visual C++, and Visual J++ languages can handle events).
| Event | Description |
|---|---|
| BeginTransComplete | Triggered after the BeginTrans operation. |
| CommitTransComplete | Triggered after the CommitTrans operation. |
| ConnectComplete | Triggered after a connection starts. |
| Disconnect | Triggered after a connection ends. |
| ExecuteComplete | Triggered after a command finishes execution. |
| InfoMessage | Triggered when a warning occurs during a ConnectionEvent operation. |
| RollbackTransComplete | Triggered after a RollbackTrans operation. |
| WillConnect | Triggered before a connection starts. |
| WillExecute | Triggered before a command is executed. |
Collection
| Collection | Description |
|---|---|
| Errors | Contains all Error objects of the Connection object. |
| Properties | Contains all Property objects of the Connection object. |