SunQuest
 
       .NET
  Home arrow .NET arrow An introduction to ADO.NET
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 
Moblin 
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? 
.NET

An introduction to ADO.NET
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2005-12-29

    Table of Contents:
  • An introduction to ADO.NET
  • Two ways to create ADO.NET objects
  • The SQL Server and OLE DB data providers
  • The SqlConnection 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    An introduction to ADO.NET


    (Page 1 of 4 )

    This article, the first of two parts, explains how ADO.NET uses classes from the .NET Framework to provide access to the data in a database. It is excerpted from chapter two of the book VB.NET Database Programming with ADO.NET, written by Anne Prince and Doug Lowe (Murach Publishing; ISBN: 1890774197).

    An overview of ADO.NET

    ADO.NET
    (ActiveX Data Objects .NET) is the primary data access API for the .NET Framework. It provides the classes that you use as you develop database applications with Visual Basic .NET as well as other .NET languages. In the two topics that follow, you’ll learn about how ADO.NET uses these classes to provide access to the data in a database and the two ways you can create ADO.NET objects in your Visual Basic programs.

    How ADO.NET works

    To work with data using ADO.NET, you use a variety of ADO.NET objects. Figure 2-1 shows the primary objects you’ll use to develop Windows-based ADO.NET applications in Visual Basic.

    To start, the data used by an application is stored in a dataset that contains one or more data tables. To load data into a data table, you use a data adapter. The main function of the data adapter is to manage the flow of data between a dataset and a database. To do that, it uses commands that define the SQL statements to be issued. The command for retrieving data, for example, typically defines a Select statement. Then, the command connects to the database using a connection and passes the Select statement to the database. After the Select statement is executed, the result set it produces is sent back to the data adapter, which stores the results in the data table.

    To update the data in a database, the data adapter uses a command that defines an Insert, Update, or Delete statement for a data table. Then, the command connects to the database and performs the requested operation.

    Although it’s not apparent in this figure, the data in a dataset is independent of the database that the data was retrieved from. In fact, the connection to the database is typically closed after the data is retrieved from the database. Then, the connection is opened again when it’s needed. Because of that, the application must work with the copy of the data that’s stored in the dataset. The architecture that’s used to implement this type of data processing is referred to as a disconnected data architecture. Although this is more complicated than a connected architecture, the advantages offset the complexity.

    One of the advantages of using a disconnected data architecture is improved system performance due to the use of fewer system resources for maintaining connections. Another advantage is that it makes ADO.NET compatible with ASP.NET web applications, which are inherently disconnected. You’ll learn more about developing ASP.NET web applications that use ADO.NET in chapters 12 through 14 of this book.

    The ADO.NET classes that are responsible for working directly with a database are provided by the .NET data providers. These data providers include the classes you use to create data adapters, commands, and connections. As you’ll learn later in this chapter, the .NET Framework currently includes two different data providers, but additional providers are available from Microsoft and other third-party vendors such as IBM and Oracle.

    Basic ADO.NET objects


    Figure 2-1.   How ADO.NET works

    Description

    • ADO.NET uses two types of objects to access the data in a database: datasets, which can contain one or more data tables, and .NET data provider objects, which include data adapters, commands, and connections.
    • A dataset stores data from the database so that it can be accessed by the application. The .NET data provider objects retrieve data from and update data in the database.
    • To retrieve data from a database and store it in a data table, a data adapter object issues a Select statement that’s stored in a command object. Next, the command object uses a connection object to connect to the database and retrieve the data. Then, the data is passed back to the data adapter, which stores the data in the dataset.
    • To update the data in a database based on the data in a data table, the data adapter object issues an Insert, Update, or Delete statement that’s stored in a command object. Then, the command object uses a connection to connect to the database and update the data.
    • The data provider remains connected to the database only long enough to retrieve or update the specified data. Then, it disconnects from the database and the application works with the data via the dataset object. This is referred to as a disconnected data architecture.
    • All of the ADO.NET objects are implemented by classes in the System.Data namespace of the .NET Framework. However, the specific classes used to implement the connection, command, and data adapter objects depend on the .NET data provider you use.

    More .NET Articles
    More By Murach Publishing


       · This article is an excerpt from the book "VB.NET Database: Database Programming with...
     

    Buy this book now. This article is excerpted from chapter two of the book VB.NET Database: Database Programming with ADO.NET, written by Anne Prince and Doug Lowe (Murach Publishing; ISBN: 1890774197). Check it out today at your favorite bookstore. Buy this book now.

    .NET ARTICLES

    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries
    - Introducing LINQ to SQL Designer using Visua...
    - Beginning LINQ to SQL Using Visual Studio 20...
    - Coding an AjaxPro.NET Based Search Engine fo...
    - Building an AjaxPro.NET Based Search Engine ...





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