Databases Reference
In-Depth Information
For the record,
batch
processing refers to sending multiple commands at one time. When
communication between consumer and provider takes place over a network, this can save
considerable time.
Transaction processing
refers to the grouping of multiple operations
into a single transaction. At the end of the transaction, the programmer can commit the
operations or rollback the data source to its state prior to any of the operations in the
transaction. One use for this is in updating related tables (as in transferring money from
one table to another). If the entire group of operations is not completed successfully, then
a rollback is probably desirable.
17.4.1 The Three-Pronged Approach to Data Manipulation
As far as data manipulation is concerned (as opposed to data definition), the main
purpose of ADO is to create a recordset that provides access to the data. As is indicated
by the object model in Figure 17-3, there are three ways to obtain a
Recordset
object. The
three methods are:
•
Create a
Recordset
object directly, and use its
Open
method, as in:
•
Dim rs As ADODB.Recordset
•
Set rs = New ADODB.Recordset
•
rs.Open ...
•
Create a
Connection
object, and use its
Execute
method to return a recordset, as
in:
•
Dim cn As ADODB.Connection
•
Dim rs As ADODB.Recordset
•
•
cn.Provider = ...
•
cn.ConnectionString = ...
•
cn.Open
•
Set rs = cn.Execute(...)
•
Create a
Command
object:
•
Dim cmd As ADODB.Command
•
Dim rs As ADODB.Recordset
•
•
Set cmd = New ADODB.Command
•
Set cmd.ActiveConnection = ...
•
cmd.CommandText = ...
•
Set rs = cmd.Execute
Note that we will tend to qualify all ADO objects with the prefix ADODB. This
will help distinguish between ADO objects and DAO objects of the same name.
In fact, the line:
Dim rs As Recordset