ASP.NET
  Home arrow ASP.NET arrow Connecting to Different Databases Using AS...
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 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
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

Connecting to Different Databases Using ASP.NET 2.0
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 18
    2006-10-09

    Table of Contents:
  • Connecting to Different Databases Using ASP.NET 2.0
  • Connecting to Microsoft SQL Server database using the database class: source code
  • Connecting to Microsoft SQL Server database using the SqlDatabase class
  • Connecting to Microsoft SQL Server database using the GenericDatabase class
  • Connecting to an Oracle database using the GenericDatabase class

  • 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


    Connecting to Different Databases Using ASP.NET 2.0


    (Page 1 of 5 )

    This is the second article in a series focusing on developing applications using ASP.NET 2.0 and the Data Access Application Block available in Microsoft's Enterprise Application Block Library for .NET 2.0.  In this article, I shall introduce you to all the database classes existing in Microsoft's Enterprise Library 2.0 along with examples.
    A downloadable file for this article is available here.

    If you are new to Microsoft application blocks, I strongly suggest you refer to my first article in this series titled “Developing ASP.NET 2.0 Applications with Microsoft Data Access Application Block.”  It gives a solid foundation for beginners.

    Database classes included in Microsoft Enterprise Library 2.0

    The database classes are the main classes used to work with databases.  The following are the classes included in Microsoft Enterprise Library 2.0.

    • Database
    • SqlDatabase
    • OracleDatabase
    • GenericDatabase

    Let us start with the “Database” class.  It is basically an abstract class. It cannot be directly instantiated. The following is the declaration for the database class.

    Public MustInherit Class Database

    Inherits System.Object

    The above class is defined in the “Microsoft.Practices.EnterpriseLibrary.Data” namespace.  You can also observe the keyword “MustInherit,” which confirms that it is an abstract class.

    You can create new database classes by inheriting from the database class. That will give the entire functionality of the Database class to your customized classes and you can further enhance them according to your requirements. This is generally used when you want to deal with any other database not included in “Microsoft Enterprise Library 2.0” (ex: Sybase). If you wanted to use the Database class directly to work with your existing databases, you need to use another class, “DatabaseFactory,” to instantiate a “Database” object.

    Let us deal with another declaration:

    Public Class SqlDatabase

    Inherits Microsoft.Practices.EnterpriseLibrary.Data.Database

    You can observe that the class SqlDatabase gets inherited from the previous class Database.  It is available in the “Microsoft.Practices.EntepriseLibrary.Data.Sql” namespace.  It has the total functionality of the Database class and has been optimized (and enhanced) to work with Microsoft SQL Server databases.  This class internally uses the Microsoft SQL Server .NET managed provider available through System.data.SqlClient.

    Similarly, we have another database class, “OracleDatabase,” defined similarly to the above class. It is mainly used to optimize applications with only Oracle databases.  It is placed in the “Microsoft.Practices.EnterpriseLibrary.Data.Oracle” namespace.

    Finally, we have another database class, “GenericDatabase,” which again gets inherited from “database” class. This is generally used when you do not know to which database you are connecting to. It is placed in the “Microsoft.Practices.EnterpriseLibrary.Data” namespace.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello guys. This is second in the series on working with Microsoft Enterprise...
     

    ASP.NET ARTICLES

    - 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...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...





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