ASP.NET
  Home arrow ASP.NET arrow Page 8 - The Connection Object
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 Connection Object
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2004-09-27

    Table of Contents:
  • The Connection Object
  • Connection State
  • The Cancel Method
  • The Execute Method
  • The Open Method
  • The OpenSchema Method
  • Properties of the Connection Object
  • The ConnectionTimeout Property and More
  • The Mode Property and Provider Property
  • The State Property and Version Property
  • Events of the Connection Object
  • The BeginTransComplete Event
  • The Disconnect Event
  • The RollbackTransComplete Event
  • Collections of the Connection Object

  • 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 Connection Object - The ConnectionTimeout Property and More


    (Page 8 of 15 )

    This property indicates how long, in seconds, to wait while trying to establish a connection before aborting the attempt and generating an error. The default is 15 seconds.

    Long = Connection.ConnectionTimeout
    Connection.ConnectionTimeout = Long

    If the timeout period expires before the connection opens, an error is generated and the connection cancelled. Setting this property to zero will force the provider to wait indefinitely.

    You cannot set this property once the connection has been established.

    The CursorLocation Property

    This property sets or returns the location of the cursor engine.

    CursorLocationEnum = Connection.CursorLocation
    Connection.CursorLocation = CursorLocationEnum

    You can set this property to one of the following CursorLocationEnum values:

    • adUseClient, to use a client-side cursor

    • adUseClientBatch, to use a client-side cursor

    • adUseServer, to use a server-side cursor
    • adUseNone, to indicate no cursor services are used (included for backward compatibility and should not be used)

    A disconnected recordset can be achieved only by setting the CursorLocation property to adUseClient.

    A Recordset created against the Connection object will inherit the value set here.

    Changing the CursorLocation property has no effect on existing Recordsets associated with a Connection. The performance issues surrounding various cursor types are discussed in Chapter 14.

    The DefaultDatabase Property

    This property indicates the default database for a Connection object.

    String = Connection.DefaultDatabase
    Connection.DefaultDatabase = String

    You can access objects in other databases by fully qualifying the objects, if the data source or provider supports this.

    For example, when using Microsoft SQL Server, you can create two recordsets on different databases:

    objConn.DefaultDatabase="pubs"

    rsOne.Open "authors", objConn, _ 
                 adOpenKeyset, adLockReadOnly, adCmdTable

    rsTwo.Open "Sales.dbo.Orders", objConn, _
                 adOpenKeyset, adLockReadOnly, adCmdTable

    The first uses the authors table from the default pubs database, and the second uses the Orders table in the Sales database. Note that this option is not available when using the RDS client-side Connection objects.

    The IsolationLevel Property

    This property indicates the level of transaction isolation for a Connection object.

    IsolationLevelEnum = Connection.IsolationLevel
    Connection.IsolationLevel = IsolationLevelEnum

    The isolation level allows you to define how other transactions interact with yours, and whether they can see your changes and vice versa.

    This value comes into effect only when you call the BeginTrans method. The provider may return the next greater level of isolation if the requested level is not available.

    The value can be one of the IsolationLevelEnum constants:

    • adXactUnspecified indicates that the provider is using a different isolation level to the one you specified, but it cannot determine which level.

    • adXactChaos indicates that a higher-level transaction has control over the records. This means that you cannot overwrite any pending changes from another user.

    • adXactBrowse or adXactReadUncommitted allows you to view uncommitted changes in another transaction. Be careful when using either of these values, because the changes in another transaction have not been committed; therefore, they could be rolled back, leaving you with invalid values.

    • adXactCursorStability or adXactReadCommitted (the default) indicates that you can view changes in other transactions only after they have been committed. This guarantees the data’s state. However, new records and deleted records will be reflected in your recordset.

    • adXactRepeatableRead doesn’t allow you to see changes made from other transactions unless you re-query the recordset. Once you have re-queried the recordset, you can see new records that might have been added by other users to the records that compose your recordset.

    • adXactIsolated or adXactSerializable indicates that transactions are completely isolated from each other. This means that all concurrent transactions will produce the same effect as if each transaction were executed one after the other.

     

    This is from ADO Programmer's Reference, by Dave Sussman (Apress, ISBN 1590593421). Check it out at your favorite bookstore today. Buy this book now.

    More ASP.NET Articles
    More By Apress Publishing


     

    ASP.NET ARTICLES

    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT