Chapter 11. ADO.NET

 < Day Day Up > 

Topics in This Chapter

  • ADO.NET Architecture: ADO.NET provides access to data using custom or generic data providers. This section looks at the classes a provider must supply that enable an application to connect to a data source and interact with it using SQL commands.

  • Introduction to Using ADO.NET: ADO.NET supports data access using a connected or disconnected connectivity model. An introduction and comparison of the two architectures is provided.

  • The Connected Model: Use of the connected model requires an understanding of the role that Connection and Command classes have in retrieving data. Examples illustrate how to create a connection and use the Command class to issue SQL commands, invoke stored procedures, and manage multi-command transactions.

  • The Disconnected Model: Disconnected data is stored in an in-memory DataTable or DataSet. The latter is usually made up of multiple DataTables that serve as a local relational data store for an application. A DataAdapter is typically used to load this data and then apply updates to the original data source. Techniques are introduced for handling synchronization issues that arise when updating disconnected data.

  • XML Data Access: Although it does not provide intrinsic XML classes, ADO.NET supports XML integration through properties and methods of the DataSet class. Examples show how to use WriteXml and ReadXml to create an XML file from a DataSet and populate a DataSet from an XML file, respectively.

ADO.NET is based on a flexible set of classes that allow data to be accessed from within the managed environment of .NET. These classes are used to access a variety of data sources including relational databases, XML files, spreadsheets, and text files. Data access is through an API, known as a managed data provider. This provider may be written specifically for a database, or may be a more generic provider such as OLE DB or ODBC (Open DataBase Connectivity). Provider classes expose a connection object that binds an application to a data source, and a command object that supports the use of standard SQL commands to fetch, add, update, or delete data.

ADO.NET supports two broad models for accessing data: disconnected and connected. The disconnected model downloads data to a client's machine where it is encapsulated as an in-memory DataSet that can be accessed like a local relational database. The connected model relies on record-by-record access that requires an open and sustained connection to the data source. Recognizing the most appropriate model to use in an application is at the heart of understanding ADO.NET. This chapter examines both models offering code examples that demonstrate the classes used to implement each.

     < Day Day Up > 


    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net