ado| Constant | Object Connection object
Property
Property name data type and purpose
The Attributes can read and write a long type, specifying whether to use a reserved transaction (retainning transactions) by the sum of two constants. A constant adxactcommitretaining indicates that a new transaction is started when the CommitTrans method is invoked, and a constant adxactabortretaning indicates that a new transaction is started when the RollbackTrans method is invoked. The default value is 0, which means that a reserved transaction is not used.
CommandTimeout can read and write a long type, specifying the time that must wait before an execute call is aborted for a related command object. The default value is 30 seconds.
ConnectionString can read and write string types, providing specific information required by a data provider or service provider to open a connection to a data source
The connectiontimeout can read and write a long type, specifying the time to wait before aborting a failed Connection.Open method call, with a default value of 15 seconds.
CursorLocation can be read-write long, determining whether to use the client (adUseClient) cursor engine or the server-side (aduseserver) cursor engine. The default value is adUseServer.
DefaultDatabase can read and write string types, if the database name is not specified in ConnectString, use the name specified here, and for SQL Server, the value is usually pubs
IsolationLevel can read and write a long type, specifying the behavior or transaction when interacting with other concurrent transactions. See IsolationLevel constant
Mode long, specifying read and Write permissions to the connection. See Mode constant
Provider can read and write to the string type, and if the name of the OLE DB data or service provider is not specified in connectionstring, the name specified is used. The default value is Msdasql (Microsoft OLE DB Provider for ODBC).
State can read and write a long type, specifying whether the connection is open, closed, or intermediate. See State constant
Version read-only string type, which returns the ADO version number.
Note: Most of the writable properties listed above are writable only when the connection is closed.
The designation of transaction isolation is truly effective only when the user defines the Begintrans...committrans...rollbacktrans method for the Connection object. If more than one database user performs a transaction at the same time, the application must specify how to respond to other transactions in the run.
Method
Method use
BeginTrans initialization of a transaction; CommitTrans and/or RollbackTrans must be followed
Close closes connection
CommitTrans commits a transaction to complete a permanent change to the data source (the BeginTrans method must be invoked before the request is used)
Execute returns a Forward-only Recordset object from the Select SQL statement and is also used to perform those that do not return a recordset statement, such as an INSERT, UPDATE, delete query, or DDL statement
Open a connection with a connection string
OpenSchema returns a Recordset object to provide structural information for the data source (metadata)
RollbackTrans cancels a transaction and restores a temporary change to the data source (the BeginTrans method must be invoked before the request is used)
Note: Only three methods of execute, open, and OpenSchema can accept argument arguments. The syntax for execute is:
Cnnname.execute Strcommand,[lngrowsaffected[,lngoptions]]
The strcommand value can be either an SQL statement, a table name, a stored procedure name, or any string that the data provider can accept. To improve performance, it is a good idea to specify the appropriate value for the Lngoptions parameter (see the constants used by the Lngoptions parameter) so that the provider interprets the statement without having to determine its type. The optional parameter lngrowsaffected returns the number of effects after the insert, UPDATE, or delete query execution. These queries return a closed Recordset object. A select query returns the lngrowsaffected value of 0 and returns an open forward-only Recordset with one or more rows of content.
Event
Event name Trigger time
BeginTransComplete BeginTrans method after execution.
Program code: [Copy Code to clipboard] Private Sub cnnname_begintranscomplet (ByVal transactionlevel as Long,byval perror as ADODB. Error,adstatus as ADODB. EventStatusEnum, ByVal pconnection as ADODB. Connection)
After the CommitTransComplete CommitTrans method executes
Program code: [Copy Code to clipboard] Private Sub connection1_committranscomplete (ByVal perror as ADODB. Error, adstatus as ADODB. EventStatusEnum, ByVal pconnection as ADODB. Connection)
After the ConnectComplete is successfully established to the connection of the data source
Program code: [Copy Code to clipboard] Private Sub connection1_connectcomplete (ByVal PE