ADO ConnectionObject
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 a Connection object to establish a connection. You can also create a connection by passing a connection string through a Command or Recordset object. However, such a connection is only suitable for a single specific simple query.
ProgID
set objConnection=Server.CreateObject("ADODB.connection")
Properties
| Property | Description |
|---|---|
| Attributes | Sets or returns a property of the Connection object. |
| CommandTimeout | Indicates the time to wait while executing a command before terminating the attempt and generating an error. |
| ConnectionString | Sets or returns the detailed information used to establish a connection to a data source. |
| ConnectionTimeout | Indicates the time to wait while establishing a connection before terminating the attempt and generating an error. |
| CursorLocation | Sets or returns the location of the cursor service. |
| DefaultDatabase | Indicates the default database for the Connection object. |
| IsolationLevel | Indicates the isolation level of the Connection object. |
| Mode | Sets or returns the access permissions of the provider. |
| Provider | Sets or returns the name of the provider of the Connection object. |
| State | Returns a value that describes whether the connection is open or closed. |
| Version | Returns the version number of ADO. |
Methods
| Method | Description |
|---|---|
| BeginTrans | Begins a new transaction. |
| Cancel | Cancels an execution. |
| Close | Closes a connection. |
| CommitTrans | Saves any changes and ends the current transaction. |
| Execute | Executes a query, SQL statement, stored procedure, or provider-specific text. |
| Open | Opens a connection. |
| OpenSchema | Returns schema information about a data source from the provider. |
| RollbackTrans | Cancels any changes made in the current transaction and ends the transaction. |
Events
Note:You cannot use VBScript or JScript to handle events (events can only be handled with Visual Basic, Visual C++, and Visual J++).
| Event | Description |
|---|---|
| BeginTransComplete | Fired after the BeginTrans operation. |
| CommitTransComplete | Fired after the CommitTrans operation. |
| ConnectComplete | Fired after a connection begins. |
| Disconnect | Fired after a connection ends. |
| ExecuteComplete | Fired after a command finishes executing. |
| InfoMessage | This event is triggered if a warning occurs during a ConnectionEvent operation. |
| RollbackTransComplete | Fired after the RollbackTrans operation. |
| WillConnect | Fired before a connection begins. |
| WillExecute | Fired before a command is executed. |
Collections
| Collection | Description |
|---|---|
| Errors | Contains all Error objects of the Connection object. |
| Properties | Contains all Property objects of the Connection object. |