home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Next, you use the data connection’s BOF (beginning-of-file) and EOF (end-of-file) methods to determine whether the current record within the recordset is the first or last record, respectively. If you are not at the beginning or end of the recordset, you can display the fields, for example. The following code uses a Do…While loop to print the transaction IDs in the recordset:

<%
If myDBConnection.EOF
   ‘=== you are at the end of the record set
Else If myDBConnection.BOF
   ‘=== you are at the beginning of the record set
Else
   Do While Not myDBConnection.EOF    ‘=== loop through the result set
      Response.Write (myDBConnection(“Transaction_ID”) & <BR>)
   Loop
End if
%>

The ADO object model includes the following objects, each of which is covered in detail in subsequent sections:

  Connection—By using the Connection object, you establish a connection with your application’s data source. In addition, you can use the Connection object to send SQL commands for a database server to process.
  Command—The Command object executes parameterized queries and stored procedures.
  Parameter—You pass parameters to a stored procedure by using the Parameter object.
  Recordset—The Recordset object holds the data the server returns as a result of processing a SQL command.
  Field—The Recordset object uses the Field object because each record returned will contain one or more fields.
  Error—The Error object logs any errors from the data source.

The Connection Object The Connection object establishes a connection with a system data source. In addition, you can use the Connection object to pass SQL instructions for the database server to process. Like most objects, Connection has a set of useful properties that you can reference. These include

  Attribute—The Attribute property specifies whether the database server will start a new transaction after the previous transaction’s commit or rollback.
  CommandTimeOut—The CommandTimeOut property specifies the amount of time the server will wait to process the command. The default is 30 seconds.
  ConnectionStringConnectionString specifies the connection string used to connect to the database.
  ConnectionTimeOut—The ConnectionTimeOut property specifies the amount of time to wait for a connection to the data source.
  DefaultDatabaseDefaultDatabase is set equal to the default database to use if your application’s data source supports connecting to multiple databases.
  Isolation—The Isolation property specifies the isolation level of your application’s connection to the data source.
  Mode—You use the Mode property to specify the connection type: either read-only or read/write.
  Provider—The Provider property is used to determine the provider of the connection to the data source.
  Version—You use the Version property to determine the ADO’s version.

You can also perform operations on the Connection object by employing one of the following methods:

  BeginTrans—By using the Connection object’s BeginTrans method, you can initiate a new transaction. Transactions are useful for maintaining data integrity within the database.
  CommitTrans—The CommitTrans method commits the current transaction to the database. If the commit is successful, your application will write all changes to the database since the previous CommitTrans or RollBackTrans.
  RollBackTrans—The RollBackTrans method cancels the current transaction. As a result, all changes to the database will revert since the previous CommitTrans or RollBackTrans.
  Close—To close your application’s connection to the database, use the Close method.
  Execute—The Execute method is used to instruct the database server to execute a SQL command. If the Execute is successful, the database server will return a result set. You can then use the Recordset object to process the result set.
  Open—To open a connection to your application’s data source, use the Open method.

The Recordset Object In the ADO model, the Recordset object holds the results of a database query. You can create a Recordset object in a number of ways. You can create the object by using the Connection or Command objects, or by using the Recordset object itself. If you use the ADO Recordset object, you get to set the resulting recordset’s properties. If you establish a Recordset using the Connection or Command object, you cannot set the resulting recordset’s properties. Listing 33.5 shows an example of using the ADO Recordset to create a new Recordset object.

Listing 33.5 Creating a New Recordset object with ADO.Recordset


Set myRecordset=Server.CreateObject(“ADO.Recordset”)
myRecordset.Source=‘’
myRecordset.RecordCount=20
myRecordset.Open


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.