Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.

Similar presentations


Presentation on theme: "Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB."— Presentation transcript:

1 Data Access

2 ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB are still the preferred means for building COM applications. ADO.NET specifically designed to build highly-scalable applications using a 3-tiered, connectionless model. Better support for “offline” applications. Most of the time in ADO.NET you are working with objects that have no active database connection. ADO.NET is based on XML.

3 ADO.NET The ADO.NET objects are implemented in the following namespaces: –System.Data - Base ADO.NET objects and types. –System.Data.Common - Classes shared by the.NET data providers. –System.Data.OleDb - OLEDB.NET data provider. –System.Data.SqlClient - SQL Server.NET data provider. –System.Data.SqlTypes - Native SQL Server data types. –ODP.NET – Oracle Data Provider (from Oracle) System.Data.OleDb and System.Data.SqlClient contain roughly the same classes. System.Data.OleDb is for using OLEDB data sources, like ADO is used for now. System.Data.SqlClient is specifically for SQL Server, and is highly optimized for performance.

4 ADO.NET Architecture.NET Data Provider Connection Transaction Command Parameters DataReader DataAdapter SelectCommand InsertCommand UpdateCommand DeleteCommand DatabaseDataSetDataSet DataTableCollection DataTable DataRowCollection DataColumnCollection ConstraintCollection DataRelationCollection XML

5 OleDbConnection / SqlConnection These classes represent an open connection to a data source. Provide the same service as the ADO Connection object. Feature the familiar properties (ConnectionString, etc.) and methods (Open, BeginTransaction, Close, etc.).

6 OleDbCommand / SqlCommand These classes represent a query command to be made against a data source. Mirrors the ADO Command object with one very big difference: Data that is returned from SELECT statements is obtained via an OleDbDataReader or SqlDataReader, which is always a forward-only, read- only stream.

7 OleDbDataReader / SqlDataReader Uses streaming methods, such as Read() to fetch data rows. Very fast, efficient object for read-only scenarios.

8 OleDbDataAdapter / SqlDataAdapter Represent a set of data commands and a database connection which are used to fill a DataSet and update the corresponding database. These objects are used for stateless batch update scenarios. Select, Insert, Update, and Delete commands are grouped together in one composite object. Used to interface a database with a DataSet object.

9 The DataSet The ADO.NET DataSet object can be described as an in- memory database. A DataSet object can contain a hierarchy of objects that represent tables, relationships, columns, rows, and constraints. It is not tied to any database product. The child objects can be manipulated in many ways. Not only can the data be updated, but additional child objects (tables, relationships, rows, etc.) can be created. The DataSet has been designed as the connectionless workhorse for the framework, servicing the need to bridge the Business Logic and Data Access layers in a multi-tiered implementation.

10 XML Throughout.NET Need to know the XML Document Object Model What does an XML object look like A “well formed” document contains an end tag for every begin tag.

11 XML Document Object Model XML Document Object Model (XML DOM) is a representation of the XML document in memory. The DOM class lets you read, write and manipulate and XML document. The.NET Framework provides classes, which enable you to navigate through an XML document and obtain relevant information.

12 XML Document Object Model XML Document Object Model (XML DOM) is a representation of the XML document in memory. The DOM class lets you read, write and manipulate and XML document. The.NET Framework provides classes, which enable you to navigate through an XML document and obtain relevant information. DOM Node structure: –Document,DocumentType, Element, Attribute, Comment,Text

13 XML in ADO.NET Can retrieve and XMLReader from a SqlCommand object Can fill a DataSet from an XML text file Can write the contents of a DataSet to an XML stream Can write the schema of a DataSet to an XML stream Can read an XML schema onto a DataSet Can create and XMLDataDocument and synchronize it with a DataSet Can persistent a DataSet with Serialization Can Deserialzie from an XML Document directly into a class. Lab 6-2


Download ppt "Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB."

Similar presentations


Ads by Google