Overview of ADO.NET
ADO.NET provides consistent access to data sources such as Microsoft SQL Server and XML, as well as to exposed through OLE DB and ODBC . Data-sharing consumer application can use ADO.NET to connect to these data sources and retrieve,manipulate,and updata the data that they contain.
ADO.NET separates data access from data manipulation into discrete components that can be used seprately or tandem.
1.Design Goals for ADO.NET(discusses the motivation and design goals behind creating ADO.NET)
ADO.NET was design to meet the needs of new programming model:disconnected data sources architecture,tight integration with XML,commom data representation with the ability to combine data from mulitple and varied data sources,and optimized facilities for interacting with a database,all native to the .NET Framework.
In creating ADO.NET ,Mircosoft embraced the following design goals; (1).Leverage current ADO(ActiveX Data Object) knowledge. (2).Support the n-tier programming model. (3).Intergrate XML support(XML is build in .NET Framework at a very fundamental level)
2.ADO.NET Architeture
As data progressing use multitier architeture ,programmers are switrhing to a disconnect approach to provide better scalability for their applications.
(1)ADO.NET Components There are two components of ADO.NET that can use to access and manipulate data: --.NET Framework data providers --The DataSet.
.NET Framework Data Providers Data Providers is explicitly designed for data manipulation and fast,forward-only,read-only acess to data. The Connection object provides connectivity to a data source. The Command object enable acess to database commands to return data,modify data,run stored procedures,and send or retrieve parameter information. The DataReader object provides a high-performance stream of data from the data source. The DataAdapter provides the bridge between DataSet object and the data source.the DataAdapter use command objects to execute SQL command at the data source to both load DataSet with data,and reconcile changes made to the data in the DataSet back to the data source.
The DataSet The ADO.NET DataSet is explicitly designed for data acess independent of any data source.it can be used to mulitple and differing data source,use with XML data,or used to manage data local to the application. The DataSet contain a collection of one or more DataTable object made up of rows and columns,as well as a primary key,foreign key,constraint,and relation information about the data int the DataTable objects.
(2).Chossing a DataReader or a DataSet How to deciding whether your application should used a DataReader or a DataSet? The DataSet to be used following: 1)Cache data locally in your application so that you can manipulata it.If you only want to read the result for a query,the DataReader is the better choice. 2)Remote data between tier or from an XML Web Service. 3)Interact with data dynamically such as binding to a Windows Forms control or combining and relation data from mulitiple data source. 4)Perform extensive processing on data without requiring an open connection to the data source,which free the connection to be used by other object.
(3).XML and ADO.NET ADO.NET leverage the power of XML to provide disconnect access to data.ADO.NET was designed hand-in-hand with the XML class.both are components of a single architecture. ADO.NET and XML class int the .NET Framework converge in the DataSet object.the DataSet object can populated from XML soruce,whether it is a file or an XML stream.The DataSet can be compliant wiht W3C XML also the schema.Beacuse of the native serialization format of the DataSet is XML,it is excellent medium for moving data between tiers,making the DataSet an optimal choices for remoting data and schema context and from an XML Web Service.
(4).Remoting or Marshaling Data Between Tiers and Clients The design of the DataSet enables you to easily transport data to clients over the Web using XML Web services, as well as allowing you to marshal data between .NET components using .NET remoting services.
3..NET Framework Data Providers A .NET Framework data provider is used for connecting to a database,executing commands,and retrieving results. The data provider included the following in the .NET Framework .NET Framework Data Provider for SQL Server System,Data.SqlClient .NET Framework Data Provider for OLE DB System,Data.OleDb .NET Framework Data Provider for ODBC System,Data.Odbc .NET Framework Data Provider for Oracle System,Data.OracleClient
(1)Core Object Of .NET Framework Data Provider Connection base class DbConnection Command base class DbCommand DataReader base class DbDataReder DataAdapter base class DbDataAdapter
In addition to the core class listed in the table above,it also contain the classes listed int the following: Transaction enable you to enlist commands in transactions at the data source. base class DbTransation CommandBuilder base class CommandBuilder ConnectionStringBulider Parameter Exception Error ClientPermission
(2)The .NET Framework Data Provider for SQL Server The .NET Framework Data Provider for SQL Server use their own protocal without add an OLE DB or Open Database Connectivity(ODBC) layer.Use the OLE DB database through The .NET Framework Data Provider for OLE DB to OE DB Serivice Component to OLE DB Provider.SQL Server only The .NET Framework Data Provider for SQL Server. The .NET Framework Data Provider for SQL Server both local and distributed transactions. for distributed transactions,the .NET Framework Data procider for SQL Server,automatically enlists in a transaction and obtains transaction detail from Windows Component Services or System.Transactions.
(3)The .NET Framework Data Provider for OLE DB The .NET Framework Data Provider for OLE DB uses native OLE DB through COM interop to enable data access. The .NET Framework Data Provider for OLE DB supports both local and distributed transactions. For distributed transactions, the .NET Framework Data Provider for OLE DB, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services The following table shows the providers that have been tested with ADO.NET SQLOLEDB Mircosoft OLE DB Provider for SQL Server MSDAORA Mircosoft OLE DB Provider for Oracle Microsoft.Jet.OLEDB.4.0 OLE DB Provider for Mircosoft Jet
(4)The .NET Framework Data Provider for ODBC The .NET Framework Data Provider for ODBC uses the native ODBC Driver Manager (DM) to enable data access. The ODBC data provider supports both local and distributed transactions. For distributed transactions, the ODBC data provider, by default, automatically enlists in a transaction and obtains transaction details from Windows 2000 Component Services The following table shows the ODBCdriver that have been tested with ADO.NET SQL Server Microsoft ODBC for Oracle Microsoft Access Driver(*.mdb)
(5)The .NET Framework Data Provider for Oracle The .NET Framework Data Provider for Oracle requires Oracle client software (8.1.7 or later) on the system before you can connect to an Oracle data source.
(6)Choosing a .NET Framework Data Provider
see the action
|