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 create a connection by passing a connection string through a Command or Recordset object. However, such connections are only suitable for a specific simple query.

ProgID

set objConnection=Server.CreateObject("ADODB.connection")

Property

Property Description
Attributes Set or return the properties of the Connection object.
CommandTimeout Indicate the time to wait before executing the command, before terminating attempts and generating errors.
ConnectionString Set or return the details information for establishing the connection data source.
ConnectionTimeout Indicate the time to wait during the establishment of a connection before terminating attempts and generating errors.
CursorLocation Set or return the location of the cursor service.
DefaultDatabase Indicate the default database of the Connection object.
IsolationLevel Indicate the isolation level of the Connection object.
Mode Set or return the access permissions of the provider.
Provider Set or return the name of the provider of the Connection object.
State Return a value describing whether the connection is open or closed.
Version Return the version number of ADO.

Method

Method Description
BeginTrans Start a new transaction.
Cancel Cancel an execution.
Close Close a connection.
CommitTrans Save any changes and end the current transaction.
Execute Execute queries, SQL statements, stored procedures, or specific text of the provider.
Open Open a connection.
OpenSchema Return schema information about the data source from the provider.
RollbackTrans Cancel any changes made in the current transaction and end 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 CommitTrans operation.
ConnectComplete Triggered after a connection starts.
Disconnect Triggered after a connection ends.
ExecuteComplete Triggered after a command is executed.
InfoMessage Triggered if a warning occurs during the ConnectionEvent operation process.
RollbackTransComplete Triggered after RollbackTrans operation.
WillConnect Triggered before a connection starts.
WillExecute Triggered before a command is executed.

Collection

Collection Description
Errors All Error Objects containing Connection Object.
Properties All Property Objects containing Connection Object.