ASP.NET
  Home arrow ASP.NET arrow Page 5 - 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 Open Method


    (Page 5 of 15 )

    This method opens a connection to a data source so that commands can be executed against it.

    Connection.Open([ConnectionString], [UserID], _ 
                           [Password], [Options]

    Parameter Type Description
    Connection String String Connection information
    (optional)
    UserID
    (optional)
    String

    User name to use when connecting

    Password (optional) String User password to use when connecting
    Options (optional) Long Extra connection options (adConnectUnspecified default value)

    Options can be one of the ConnectOptionEnum constants. At the moment, the only constants supported are adAsyncConnect (which indicates the connection should be made asynchronously) and adConnectUnspecified (the default, which indicates a synchronous connection is to be made).

    The ConnectionString property takes its value from the ConnectionString argument if used.

    Values passed in the UserID and Password arguments override similar values passed in the ConnectionString argument-unless the Password you supply in the argument is blank, in which case the ConnectionString password still seems to take effect.

    Under version 2.8, connecting to the data source depends upon the zone in which the data source originates and whether the provider supports Integrated Security (SQL, MSDataShape, Remote, and Directory Services). If the provider supports Integrated Security and the user credentials are supplied as part of the connection string, the connection is always allowed. If the provider supports Integrated Security and the credentials aren’t supplied (i.e., the current user credentials are used), or the provider doesn’t support Integrated Security, then the connection depends upon the IE settings for user authentication and logon, which can be:

    • Automatic logon with current user name and password-the connection is allowed.

    • Prompt for user name and password-the connection is not allowed.

    • Automatic logon only in Intranet zone-the user is prompted with a security warning.

    • Anonymous logon-the connection is not allowed.

    Some typical connections strings are shown in the following examples. For the ODBC Provider connecting to an Access database, you would use:

    Driver={Microsoft Access Driver (*.mdb)}; DBQ=database_file

    The DBQ argument points to the physical path name of the Access database. To connect to SQL Server, again using ODBC, you would use:

    Driver={SQL Server}; Server=server_name;
            Database=database_name;
            UID=user_name; PWD=user_password

    Switching over to the native OLE DB drivers, connecting to Access would be like this:

    Provider=Micrsoft.Jet.OLEDB.4.0; Data Source=database_file

    For SQL Server, using the native driver, it would be:

    Provider=SQLOLEDB; Data Source= server _ name; Initial
                Catalog= database _ name; User Id= user _ name;
                                  Password= user _ password

    More details of the different connection strings you can use for the more common OLE DB Providers appear under the ConnectionString property and in Chapter 2. 

    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

    - Disadvantages of the ASP.NET MVC Framework
    - 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

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




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