1 / 17

ADO.NET

ADO.NET. ADO.NET is the Successor to Active-x Data Object (ADO 2.6) We can use ADO in .NET Framework but our performance will be slow when working with COM Layer, Because .NET Framework does not support COM Variant Type an ADO use’s it for Field & Recordset Obj.

morrisonl
Download Presentation

ADO.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADO.NET ADO.NET is the Successor to Active-x Data Object (ADO 2.6) We can use ADO in .NET Framework but our performance will be slow when working with COM Layer, Because .NET Framework does not support COM Variant Type an ADO use’s it for Field & Recordset Obj. If we use the ADO Recordset in .NET then every time CLR have to perform Type-Conversion for each Field & this Type-Conversion can become costly when working with Databases. You will get a truly disconnected data architecture. Tight Integration with XML. A common Representation with ability to combine data from Different Databases.

  2. Goals of ADO.NET • Current ADO Knowledge • Support N-Tier Programming Model. • Provide support for XML. Easy to create Distributed, Data sharing Application Provide Interface to communicate with OLEDB Data source such as SQL Server & Oracle. In Distributed Application there is a concept of Disconnected data. ADO.NET uses XML to exchange data between program or with web page that means it enables programmer to easily separate the data processing and interface on separate server. That will improve performance and maintainability of system. Once you get the Data the connection with D.S is dropped after you can work with Data Locally. So, It frees up the DB server Resources.

  3. ADO.NET architecture • The following diagram illustrates the relationship between a .NET Framework data provider and a DataSet.

  4. ADO.NET Components • There are two components of ADO.NET that you can use to access and manipulate data: • .NET Framework data providers • The DataSet • .NET Framework Data Providers The .NET Framework Data Providers are components that have been explicitly designed for data manipulation and fast, forward-only, read-only access to data. 1) The Connection object provides connectivity to a data source. 2) The Command object enables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information. 3) The DataReader provides a high-performance stream of data from the data source. 4) The DataAdapter provides the bridge between the DataSet object and the data source. The DataAdapter uses Command objects to execute SQL commands at the data source to both load the DataSet with data, and reconcile changes made to the data in the DataSet back to the data source.

  5. ADO.NET Components • The DataSet The ADO.NET DataSet is explicitly designed for data access independent of any data source. As a result, it can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet contains a collection of one or more DataTable objects made up of rows and columns of data, as well as primary key, foreign key, constraint, and relation information about the data in the DataTable objects.

  6. Choosing a DataReader or a DataSet • While deciding whether your application should use a DataReader or a DataSet, you should consider the type of functionality that your application requires. • Use a DataSet to do the following: 1) Cache data locally in your application so that you can manipulate it. If you only need to read the results of a query, the DataReader is the better choice. 2) Remote data between tiers or from an XML Web service. 3) Interact with data dynamically such as binding to a Windows Forms control or combining and relating data from multiple sources. 4) Perform extensive processing on data without requiring an open connection to the data source, which frees the connection to be used by other clients.

  7. Choosing a DataReader or a DataSet • If you do not require the functionality provided by the DataSet, you can improve the performance of your application by using the DataReader to return your data in a forward-only, read-only fashion. Although the DataAdapter uses the DataReader to fill the contents of a DataSet By using the DataReader you can boost performance because you will save memory that would be consumed by the DataSet, as well as avoid the processing required to create and fill the contents of the DataSet.

  8. XML and ADO.NET • ADO.NET leverages the power of XML to provide disconnected access to data. ADO.NET was designed hand-in-hand with the XML classes in the .NET Framework; both are components of a single architecture. • ADO.NET and the XML classes in the .NET Framework converge in the DataSet object. The DataSet can be populated with data from an XML source, whether it is a file or an XML stream. • The DataSet can be written as World-Wide Web Consortium (W3C) compliant XML, including its schema as XML Schema definition language (XSD) schema, regardless of the source of the data in the DataSet. • Because of the native serialization format of the DataSet is XML, it is an excellent medium for moving data between tiers, making the DataSet an optimal choice for remoting data and schema context to and from an XML Web service.

  9. Data Namespaces • System.Data- consists of the classes that constitute the ADO.NET architecture. • System.Data.Common- contains classes shared by the .NET Framework data providers. • System.Xml- classes that provide standards-based support for processing XML. • System.Data.OleDb– classes that make up the .NET Framework Data Provider for OLE DB-compatible data sources. • System.Data.SqlClient– classes that make up the .NET Framework Data Provider for SQL Server. • System.Data.Odbc- classes that make up the .NET Framework Data Provider for ODBC. • System.Data.OracleClient- classes that make up the .NET Framework Data Provider for Oracle. • System.Transactions- classes that allow you to write your own transactional application and resource manager. Specifically, you can create and participate in a transaction (local or distributed) with one or multiple participants.

  10. Benefits of ADO.NET Interoperability:- ADO.NET applications can take advantage of the flexibility and broad acceptance of XML. Because XML is the format for transmitting datasets across the network, any component that can read the XML format can process data. Maintainability:- It Divides the server’s Task in 1) Logic-Processing. 2) User Interface Processing on two separate Tier on separate machine, Tiers can Transmit the Data through XML Formatted Dataset easily Programmability:- The ADO.NET components provide Data Access functionality which is 1.Easy to Read 2.Easy to Write 3.Quick 4. Safe Performance:- Because Data-Type conversion is not take place. Scalibility:- By Using Disconnected DataBase There is no Database Locks & Active Connection so, we can serve a no. of Users.

  11. Difference B/W ADO – ADO.NET • Memory-Resident Data Representation:- ADO :- Uses the Recordset object, which holds Single Row of data ADO.NET :- Uses the DataSet Object, which contains Tables represents by DataTable Object. • Relationship b/w Multiple Tables :- ADO:- It Requires the JOIN Query for …… ADO.NET:- Supports DataRelation Object to the Row of First DataTable with other. • Data Navigation :- ADO:- Traverses Rows in a Recordset sequentially by using .MoveNext Method. ADO.NET:-Dataset uses Non-Sequencial access to Rows like Array, Rows collection through DataTable allows you to access Rows by Index.

  12. Difference B/W ADO – ADO.NET • Disconnected Access:- ADO:-Provided by Recordset but We required Activeconnection property there. Communicate with DB through OLEDB. ADO.NET:- Provided by Dataset with Data Adapter which directly communicate OLEDB or SQL. • Programmability:- ADO:-Recordset of COM Variant Data Types corresponds to FieldName & TableName. ADO.NET:- Use XML, Data in Dataset & Datareader objects which makes code easy to Read & Write. • Sharing Disconnected Data b/w Tiers:- ADO:- Use COM to Transmit Disconnected Recordset, so Require Type conversion & Resources for that. ADO.NET:- Transmit a Dataset as XML, No Restriction on Data Types so No Type Conversion.

  13. Difference B/W ADO – ADO.NET • Transmitting Data through Firewalls :- ADO:- Firewall Restricts the COM Application ADO.NET:- Dataset object use XML, Which can pass through Firewalls. 8.Scalability:- ADO:- Uses Recordset object, DB Locks & Active connection for long time so it consumes the DB Resources. ADO.NET:- Disconnected data Access to DataBase so No DB Lock, No Connection & No Consumption of DB Resources

  14. Block Diagram Classic ADO ADO.NET Connection Command DataAdapter Connection DataSet DataReader Command RecordSet DataRelations DataTables DataRows DataColumns DataView

  15. Working Data - The DataSet • An in-memory cache of data from a data source • Common way to represent and manipulate data • Universal data container • Not just for use with databases • Logical or physical representation of data • Designed to be disconnected from the data source • Connect, execute query, disconnect • Can use XML • To read and write data • To read and write XMLSchema

  16. Properties & Methods of Interest • Collections are used to add & remove tables & relations • Properties of Interest: • Tables: Returns the collection of DataTable objects • Relations: Returns the collection of DataRelations • Using Properties Samples: • myDataSet.Tables.Add( myTable ); • myDataTableCollection = myDataSet.Tables

  17. The DataTable • May be mapped to a physical table in the data source • Can be related to one another through DataRelations • Optimistic concurrency or locking - model • Properties of Interest: • Columns: Returns ColumnsCollection of DataColumns • Rows: Returns DataRow objects as a RowsCollection • ParentRelations: Returns the RelationsCollection • Constraints: Returns the table’s ConstraintsCollection • DataSet: Returns the DataSet of the DataTable • PrimaryKey: Gets the DataColumns that make up the table’s primary key

More Related