ASP.NET
  Home arrow ASP.NET arrow Page 9 - The ADO Object Model
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

The ADO Object Model
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 15
    2004-11-09

    Table of Contents:
  • The ADO Object Model
  • The Main ADO Objects
  • The Other ADO Objects
  • The ADOX Object Model
  • ADOX Supported Features
  • OLE DB Providers
  • Connection Strings
  • Asynchronous Processing
  • Connection Events

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The ADO Object Model - Connection Events


    (Page 9 of 9 )

    There are nine Connection events:

    • BeginTransComplete is called after a BeginTrans method has completed.

    • CommitTransComplete is called after a CommitTrans method has completed.

    • RollbackTransComplete is called after a RollbackTrans method has completed.

    • WillConnect is called just before a connection is established.

    • ConnectComplete is called after a connection is established.

    • Disconnect is called after a connection has disconnected.

    • WillExecute is called before an Execute method is run.

    • ExecuteComplete is called after an Execute method has completed.

    • InfoMessage is called when the provider returns information messages.

    An example of the …Complete events could be to indicate to users the status of their connection. The individual events for a Connection are discussed in more detail in Chapter 3.

    Recordset Events

    The Recordset has more events than the Connection:

    • FetchProgress is called periodically during an asynchronous recordset creation.

    • FetchComplete is called when the recordset has been fully populated with its records.

    • WillChangeField is called before an action causes a field to change.

    • FieldChangeComplete is called after an action caused a field to change.

    • WillMove is called before an action causes the current record to change.

    • MoveComplete is called after an action caused the current record to change.

    • EndOfRecordset is called when there is an attempt to move beyond the end of the recordset.

    • WillChangeRecord is called before an action causes the data in the current record to change.

    • RecordChangeComplete is called after an action caused the data in the current record to change.

    • WillChangeRecordset is called before an action causes a change to an aspect of the record-set (such as a filter).

    • RecordsetChangeComplete is called after an action caused the recordset to change.

    The Will… events can be used to notify the user that an action may change data or may change the underlying records in the recordset.

    A word of caution when using the new ADO Data Control in Visual Basic 6: This automatically updates records when using the video-style buttons to move around the records. This differs from the standard Data Control. If you change a field, then the WillChangeField event is called, and if the value is not correct, you can cancel the action. However, it is the Update that is cancelled, not the move. It’s not a major problem, but something to bear in mind.

    The individual events for a Recordset are discussed in more detail in Chapter 5.

    Object Usage

    Some people are confused about when to use which object. After all, the Connection, Command, and Recordset objects are all capable of returning a recordset of data. There are only a few hard-and-fast rules, but in general, here’s what you should do:

    • If you only ever need to run queries that don’t return a recordset, and those queries are not parameterized statements (such as stored procedures) with output parameters, then use the Connection object and the Execute method.
    • If you need to use stored procedures with output parameters, you must use the Command object.

    • If you need to specify the cursor type or lock type, then you must use a Recordset object.

    • If you are creating only one or two recordsets of data, then you can use the Recordset to implicitly establish a connection to a data store by passing in a connection string in the ActiveConnection parameter of a Recordset object’s Open method.

    • If you are creating two or more recordsets, then explicitly create a Connection object first, then reuse the Connection object when opening the Recordset objects. Remember that each time you connect to a data store with a connection string, a new connection is opened or retrieved from the connection pool.

    Summary

    This chapter has introduced the ADO object model, examined how you go about connecting to data stores, and looked at the connection strings for a variety of OLE DB providers. It has also briefly introduced asynchronous processing and the use of events, the details of which are covered in the Chapters 3 and 5, where the Connection and Recordset objects are discussed in more detail.

    Most of the rest of the book is concerned with the properties, methods, and events of the various ADO objects and related libraries, such as ADOX, ADOMD, and Jet Replication Objects (JRO).

    Buy the book!

    This chapter is from ADO Programmer's Referencep,by David Sussman. (Apress Books, 2004, ISBN: 1590593421).  Check it out at your favorite bookstore today.

    Buy this book now!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek