The ADO Connection object provides the means to obtain an open connection to a data source. Through this open connection, you can access and manipulate a database.
In order to query a database, you do not need to explicitly create a Connection object.
A connection can be made by passing a connection string via a Command or Recordset object.
However, such a connection is only good for that specific, single query.
If you desire to access a data source multiple times,
it is far more efficient to establish a connection using the Connection object.
In a similar vein, you can pass a query string using the Execute method of the Connection
object.
However, a Connection object query lacks the superior functionality of a Command object query.
Only the Connection and Recordset objects have events.
Note that only the Visual Basic, Visual C++, and Visual J++ languages can handle these events.
You cannot handle an event using the VBScript or JScript scripting languages.
Carl Prothman of Able Consulting, Inc. maintains a web site
containing sample ADO connection strings for ODBC DSN, ODBC DSN-Less, OLE DB Provider, and MS Remote.
The Guru highly recommends you visit this extremely useful site.
Syntax: long
= connectionobject.Attributes
connectionobject.Attributes
= long
Sets or returns a long value defining the characteristics of a Connection object.
Syntax: long
= connectionobject.CommandTimeout
connectionobject.CommandTimeout
= long
Sets the number of seconds to wait while attempting an Execute method call before terminating the attempt and generating an error message.
Syntax: string
= connectionobject.ConnectionString
connectionobject.ConnectionString
= string
Sets or returns a string value that contains the details used to create a connection to a data source.
Syntax: string
= connectionobject.ConnectionTimeout
connectionobject.ConnectionTimeout
= string
Sets the number of seconds to wait while attempting to create a connection before terminating the attempt and generating an error message.
Syntax: long
= connectionobject.CursorLocation
connectionobject.CursorLocation
= long
Sets or returns a long value used to select between various cursor libraries accessible through the provider.
Syntax: string
= connectionobject.DefaultDatabase
connectionobject.DefaultDatabase
= string
Sets or returns a string value that is the default name of the database available from the provider for a Connection object.
Syntax: IsolationLevelEnum = connectionobject.IsolationLevel
connectionobject.IsolationLevel
= IsolationLevelEnum
Sets or returns the transaction isolation level (the IsolationLevelEnum value) of a Connection object.
Syntax: ConnectModeEnum
= connectionobject.Mode
connectionobject.Mode
= ConnectModeEnum
Sets or returns the provider access permission (the ConnectModeEnum value) for a Connection object.
Syntax: string
= connectionobject.Provider
connectionobject.Provider
= string
Sets or returns the string value that is the provider name.
Syntax: long = connectionobject.State
Returns a long value (the ObjectStateEnum value) describing if the connection is open or closed.
Syntax: string = connectionobject.Version
Returns a string value that is the ADO version number.
Syntax: long = connectionobject.BeginTrans
Begins a new transaction and returns a long value indicating the number of nested transactions.
Syntax: connectionobject.Cancel
Cancels the execution of a pending Execute or Open call.
Syntax: connectionobject.Close
Closes a connection.
Syntax: connectionobject.CommitTrans
Saves any changes and ends the current transaction. It can also be set to automatically start a new transaction.
Syntax: Syntax for non-row-returning:
connectionbject.Execute
CommandText, RecordsAffected, Options
Syntax for row-returning:
Set rsobject = connectionbject.Execute (CommandText, RecordsAffected, Options)
Executes the query, SQL statement, stored procedure, or provider-specific text.
Syntax: connectionobject.Open ConnectionString, UserID, Password, Options
Opens a physical connection to a data source.
Syntax: Set rsobject = connectionobject.OpenSchema (QueryType, Criteria, SchemaID)
Returns descriptive schema information from the provider about the data source.
Syntax: connectionobject.RollbackTrans
Cancels any changes that have occurred during the current transaction and then ends the transaction. It can also be set to automatically start a new transaction.
The Errors Collection contains all of the Error objects that were created as the result of a single failure involving the provider. Each time a failure occurs involving the provider, the Errors Collection is cleared and the new Error objects that have been created are inserted into the collection.
The Properties Collection is a collection of Property objects. Each Property object contains a single piece of information, called a dynamic property, about the database provider. By referring to the Properties Collection, each connection to a provider can be tailored specifically by ADO to suit the exact needs of that provider.
Syntax: BeginTransComplete TransActionLevel, pError, adStatus, pConnection
After a BeginTrans operation has finished executing,you can call this event to trigger other operations.
Syntax: CommitTransComplete pError, adStatus, pConnection
After a CommitTrans operation has finished executing,you can call this event to trigger other operations.
Syntax: ConnectComplete pError, adStatus, pConnection
After a connection has started, you can call this event to provide information on the success of the connection.
Syntax: Disconnect adStatus, pConnection
After a disconnection, you can call this event to provide information on the success of the disconnection.
Syntax: ExecuteComplete RecordsAffected, pError, adStatus, pCommand, pRecordset, pConnection
After a command has finished executing, you can call this event to provide information on the successof the command and the number of records affected.
Syntax: InfoMessage pError, adStatus, pConnection
This event is called if a warning occurs during a ConnectionEvent operation.
Syntax: RollbackTransComplete pError, adStatus, pConnection
After a RollbackTrans operation has finished executing,you can call this event to trigger other operations.
Syntax: WillConnect ConnectionString, UserID, Password, Options, adStatus, pConnection
This event can be called before the connection starts.You can change any of the parameters and even cancel the connection.
Syntax: WillExecute Source, CursorType, LockType, Options, adStatus, pCommand, pRecordset, pConnection
This event is called before a pending command is executed.It allows you to change the execution parameters.