Presentation is loading. Please wait.

Presentation is loading. Please wait.

Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.

Similar presentations


Presentation on theme: "Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET."— Presentation transcript:

1 Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET

2 ADO.NET Overview Looking Back  ADO (ActiveX Data Objects) Simple component-based, object-oriented interface Provides a programming model to OLE DB accessible outside of C++

3 ADO.NET Overview What Is ADO.NET?  ADO.NET is a collection of classes, interfaces, structures, and enumerated types that manage data access from relational data stores within the.NET Framework These collections are organized into namespaces: System.Data, System.Data.OleDb, System.Data.SqlClient, etc.  ADO.NET is an evolution from ADO.The next generation of ADO

4 Managed Providers  It performs operation of communicating with the database  Similar to ODBC driver or OLEDB provider  ADO.NET currently provides two distinct managed providers The SQL Server managed provider is used with SQL server OLEDB managed provider is used to communicate with any OLEDB compliant database like Access or Oracle.

5 Data access namespaces  System.Data  System.Data.OleDb  System.Data.SQLClient  System.Data.SQLTypes  System.Data.XML

6 Main objects of ADO.NET  OleDbConnection / SQLConnection  OleDbCommand / SQLCommand  OleDbDataReader / SQLDataReader  OleDbDataAdapter / SQLDataAdapter  OleDbParameter / SQLParameter  DataSet  DataTable  DataView  DataRow  DataColumn

7 SQL Managed Provider SQL Server Database ADO.NET Overview Managed Providers ADO.NET Managed Provider ADO Managed Provider OLE DB Provider Database Your Application

8 ADO.NET Overview Data Access Styles  Connected: Forward-only, read-only Application issues query then reads back results and processes them “Firehose” cursor DataReader object  Disconnected Application issues query then retrieves and stores results for processing Minimizes time connected to database DataSet object

9 ADO.NET objects  These objects are divided into two groups  To manage data (DataSet,DataTable,DataRow,DataRelation) To connect data(Connections,DataReader)

10 What is DataSet,DataAdapter  Dataset is an in-memory disconnected representation of data from actual database  Since dataset is totally disconnected from the database there must be some means of communication between the dataset and the database  DataAdapter is used for that purpose.

11 Functions of DataAdapter  Populate the dataset by fetching data from database  Updating changes made to the dataset back to the database Changes made to the dataset are not written to the database unless explicitly updated via DataAdapter.

12 DataSet  The DataSet object stores the disconnected data from a database and allows you to manipulate it as a single object  The DataSet Objects inturn has two other objects DataTable,DataRelation

13 ADO.NET Classes DataSet DataSet DataTable DataRelation DataRow DataColumn

14 DataTable  It consists collection of DataRow and DataColumn  DataRow  Represents a single row of information  Individual values can be accessed using the field names  DataColumn  Does not hold any data instead information about the column such as Datatype,default value

15 DataRelation  Each DataRelation Object represents a single parent/Child relationship between two different datasets  DataView-Used to bind data in the DataTable object  Displays data or it can also filter and sort data

16 ADO.NET Classes DataRelation  Relates two DataTables via DataColumns  DataType value of both DataColumns must be identical  Updates can be cascaded to child DataTables  Modifications that invalidate the relation are disallowed

17 The data Source Interaction Web page Connection object commandDataReader Data Store

18 ADO.NET Classes IDbConnection Interface  Creates a unique session with a data source  Implemented by SqlDbConnection and OleDbConnection  Functionality Open, close connections Begin transactions IDbTransaction provide Commit and Rollback methods  Used in conjunction with IDbCommand and IDataAdapter objects

19 ADO.NET Classes IDbCommand Interface  Represents a statement to be sent to a data source Usually, but not necessarily SQL  Implemented by OleDbCommand and SqlCommand  Functionality Define statement to execute Execute statement Pass and retrieve parameters Create a prepared (compiled) version of command

20  ExecuteReader returns rows  ExecuteNonQuery doesn’t  ExecuteScalar returns single value

21 ADO.NET Classes System.Data.OleDb Namespace  Managed provider for use with OLEDB providers SQLOLEDB (SQL Server) – use System.Data.SQL MSDAORA (Oracle) JOLT (Jet) OLEDB for ODBC providers  OleDbConnection, OleDbCommand and OleDbDataReader classes  Classes for error handling  Classes for connection pooling

22 ADO.NET Classes DataSet  A collection of tables  Has no knowledge of the source of the data  Keeps track of all relationships among tables  Rich programming model (has objects for tables, columns, relationships, and so on)  Remembers original and current state of data  Can dynamically modify data and metadata  Native serialization format is XML  Located in System.Data

23 ADO.NET Classes System.Data.SqlClient Namespace  Managed provider native to SQL Server  Built on TDS (Tabular Data Stream) for high performance in SQL Server  SqlConnection, SqlCommand and SqlDataReader classes  Classes for Error handling Connection pooling (implicitly enabled by default )  System.Data.SqlTypes provides classes for native SQL Server data types

24 ADO.NET Classes IDataAdapter Interface  Populates or sends updates to a DataSet  Implemented by OleDbDataAdapter and SqlDataAdapter  Not connection based  Represents an asynchronous approach  A superset of a command object  Contains four default command objects for Select, Insert, Update, and Delete

25 Conclusion  Database Theory and History  Relational Database Concepts and Terminology  ADO.NET Overview  ADO.NET Classes

26 Appendix ADO vs. ADO.NET  ADO is a slower automation layer over OLE DB for use in Visual Basic, etc.  ADO.NET provides direct, fast access to data from any language  ADO.NET essentially has merged OLE DB and ADO into a single layer

27 Appendix ADO vs. ADO.NET FeatureADOADO.NET Memory-resident Data Representation Uses RecordSet, which can contain one table Uses DataSet, which can contain one or more tables represented by DataTables Relationship Between Multiple Tables Require the JOIN querySupports the DataRelation object Data VisitationScans RecordSet rows sequentially Uses a navigation paradigm for non- sequential access Disconnected AccessProvided by RecordSet but typically supports connected access Communicates with standardized calls to the DataAdapter

28 Appendix ADO vs. ADO.NET FeatureADOADO.NET ProgrammabilityUses Connection object to transmit commands Uses strongly typed programming characteristics of XML Sharing Disconnected Data Between Tiers or Components Uses COM marshalling to transmit disconnected Recordset Transmits a DataSet with an XML file Transmitting Data Through Firewalls Problematic because firewalls are typically configured to prevent system-level requests Supported, DataSet object use XML, which can pass through firewalls ScalabilityDatabase locks and active database connections for long durations Disconnected access to database data without retaining database locks


Download ppt "Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET."

Similar presentations


Ads by Google