爱猫的狗

拥抱变化

导航

Microsoft Windows Forms QuickStarts Tutorial - Building Applications

ADO.NET Overview

Connections

Connections are used to 'talk to' databases, and are respresented by provider-specific classes such as SQLConnection. Commands travel over connections and resultsets are returned in the form of streams which can be read by a DataReader object, or pushed into a DataSet object.

Commands

Commands contain the information that is submitted to a database, and are represented by provider-specific classes such as SQLCommand. A command can be a stored procedure call, an UPDATE statement, or a statement that returns results. You can also use input and output parameters, and return values as part of your command syntax. The example below shows how to issue an INSERT statement against the Northwind database.

DataReaders

The DataReader object is somewhat synonymous with a read-only/forward-only cursor over data. The DataReader API supports flat as well as hierarchical data. A DataReader object is returned after executing a command against a database. The format of the returned DataReader object is different from a recordset

DataSets and DataAdapters

DataSets
The DataSet object is similar to the ADO Recordset object, but more powerful, and with one other important distinction: the DataSet is always disconnected. The DataSet object represents a cache of data, with database-like structures such as tables, columns, relationships, and constraints. However, though a DataSet can and does behave much like a database, it is important to remember that DataSet objects do not interact directly with databases, or other source data. This allows the developer to work with a programming model that is always consistent, regardless of where the source data resides. Data coming from a database, an XML file, from code, or user input can all be placed into DataSet objects. Then, as changes are made to the DataSet they can be tracked and verified before updating the source data.

DataAdapters (OLEDB/SQL)
The DataAdapter object works as a bridge between the DataSet and the source data.
 The DataAdapter object uses commands to update the data source after changes have been made to the DataSet. Using the Fill method of the DataAdapter calls the SELECT command; using the Update method calls the INSERT, UPDATE or DELETE command for each changed row.

Section Summary

  1. ADO.NET is the next evolution of ADO for the .Net Framework.
  2. ADO.NET was created with n-Tier, statelessness and XML in the forefront. Two new objects, the DataSet and DataAdapter, are provided for these scenarios.
  3. ADO.NET can be used to get data from a stream, or to store data in a cache for updates.
  4. There is a lot more information about ADO.NET in the documentation.
  5. Remember, you can execute a command directly against the database in order to do inserts, updates, and deletes. You don't need to first put data into a DataSet in order to insert, update, or delete it.
  6. Also, you can use a DataSet to bind to the data, move through the data, and navigate data relationships.
-------------------------------------------------------------------------------------------

XML Web services created using ASP.NET Overview

posted on 2005-11-03 21:29  anf  阅读(248)  评论(0编辑  收藏  举报