ASP.NET
  Home arrow ASP.NET arrow Introducing ADO.NET with ASP.NET 2.0
Iron Speed
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 
Actuate Whitepapers 
VeriSign Whitepapers 
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

Introducing ADO.NET with ASP.NET 2.0
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2007-09-19

    Table of Contents:
  • Introducing ADO.NET with ASP.NET 2.0
  • Populating a ListBox control from the Northwind database
  • Explaining the code
  • Using Exception Handling code

  • 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

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Introducing ADO.NET with ASP.NET 2.0


    (Page 1 of 4 )

    This is the first article in a series that I have written for anyone who wants to learn how to use ADO.NET technology, with an ASP.NET 2.0 page, to retrieve and update data. I assume that you have knowledge of C#, ASP.NET and Visual Studio.NET 2005.

    In this article, we introduce the basics of ADO.NET. In subsequent articles we will talk more about how you can do advanced database operations from web pages. I will also show you code examples as I always present them in my articles.

    ADO.NET is a set of classes that are organized in a number of namespaces. These namespaces provide developers access to databases to retrieve and update data. The classes of ADO.NET provide us with the means to access databases and execute T-SQL code that retrieves, inserts, updates and deletes data. It's critical to understand that ADO.NET depends on the concepts of data providers. ADO.NET doesn't have a general connection class that would access any database. ADO.NET has separated its functionality through the ADO.NET Data Providers.

    A Data Provider is a set of classes that provide access to a specific data source for retrieving, updating and deleting operations between your application and the data source. Those classes are optimized to access and deal with that specific data source. This is the point of creating Data Providers and not using general classes to access any data source.

    An ADO.NET Data Provider has the following classes:

    Connection class: The connection class is used to connect to the data source. Note that different ADO.NET Data Providers have different connection classes. For example, the SQL Server Data Provider has the SqlConnection class, the Oracle Data Provider has the OracleConnection class and the OleDb Data Provider has the OleDbConnection class. So we don't have a class called connection because ADO.NET doesn't give us the ability to use general classes to access different data sources.

    Command class: The command class is used to execute SQL statements on the data source. As you might have guessed there is nothing called a command class in ADO.NET and different ADO.NET Data Providers have different command classes. The SQL Server Data Provider has a SqlCommand class and the same applies to the other Data Providers; each one has its own command class.

    Data reader class: This class provides access to a database table in a read-only forward-only behavior. The SQL Server Data Provider has the SqlDataReader class; other Data Providers also have their own implementations of the data reader. For example, the OleDbDataReader is the class for the OleDb Data Provider and so on.

    Data adapter class: The data adapter class submits changes made to the data in your application. This data is in the form of a DataSet object to the data source. The SQL Server Data Provider has the SqlDataAdapter class; other Data Providers also have their own implementations of the data adapter. For example, the OleDbDataAdapter is the class for the OleDb Data Provider and so on.

    ADO.NET is shipped with four Data Providers, but you can create your own provider if you need to access another data source that has no Data Provider. The four Data Providers are as follows: 

    1. The SQL Server Data Provider is used, and optimized, to access SQL Server 2005, 2000 and version 7.0 databases. Its classes lives in the  System.Data.SqlClient namespace.
    2. The Oracle Data Provider is used to access Oracle databases and its classes lives in the System.Data.OracleClient namespace. 
    3. The OLE DB Data Provider is used to access any data source that has an OLE DB Driver. Its classes lives in the System.Data.OleDb namespace. 
    4. The ODBC Data Provider is used to access any data source that has an ODBC Driver. Its classes lives in the  System.Data.Odbs namespace.

    Throughout the series I will be using the SQL Server Data Provider because I'm using SQL Server as the database server for all of my code examples. In one of the next articles I will show you how you can write generic data access code that you can use to access any data source as long as it has an ADO.NET Data Provider. So enough theory and let's get to the code examples.

    More ASP.NET Articles
    More By Michael Youssef


       · Yes you can use the SqlDataSource control without knowing much about ADO.NET 2.0,...
     

    ASP.NET ARTICLES

    - 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...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...





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