You are on page 1of 78

ADO.NET 2.

By

SRIRAM. B
Objective
 Introduction to ADO.NET &Features of ADO.NET
 ADO.NET Object Model
 Connecting database through Connection Object
 Executing Queries through Command Object
 Retrieving records through DataReader
 Connect to a database by using DataAdapter
 Dataset Object Model
 Accessing Databases through Dataset
 Command Builder
 Data Relation Object
 ADO.NET 2.0 Features
Introduction to
ADO.NET
Introduction to ADO.NET

 Is a model used by Visual Basic .NET applications to


communicate with a database for retrieving,
accessing, and updating data.

 Uses a structured process flow to interact with a

database
Feature of
ADO.NET
Features of ADO.NET

✓ Disconnected data architecture —


Applications connect to the database only
while retrieving and updating data.

✓ Data cached in datasets — ADO.NET is


based on a disconnected data structure.
Therefore, the data is retrieved and stored
in datasets.

✓ Data transfer in XML format — ADO.NET


uses XML for transferring information from
a database into a dataset and from the
dataset to another component.

✓ Interaction with the database is done


through data commands.
ADO.NET Object
Model
ADO.NET Object Model

DATA PROVIDER

Establishes
connection with
the database
CONNECTION
Retrieves data in a
VISUAL BASIC Accessing retrieved read-only,
.NET data forward only mode
APPLICATION DATA READER
(WINDOWS/ WEB Executes a command
FORM)
to retrieve data from
the database DATABASE

COMMAND

Accessing retrieved data Transfers data to


the dataset and
reflects the changes
made in the dataset
Filling dataset with data to the database
DATASET
DATA ADAPTER
ADO.NET Data
Provider
DataProvider

 Is used for connecting to a database,


retrieving data, and storing the data.
 Is of two types:

OLE DB data provider

SQL Server data provider
Components of Data
Provider
Components of DataProvider

 Connection
 Command
 DataReader
 DataAdapter
 DataSet
Connection
Object
Connection Object

 Used to establish a connection


with a data source
 Some commonly used properties
and methods:
- ConnectionString property
- State property
- Open()method
- Close()method
Command
Object
Command Object

•Is a SQL statement or a stored


procedure that is used to retrieve,
insert, delete, or modify data from a
data source.
•Is an object of the OleDbCommand or
SQLCommand class.
DataReader
Data Reader
 Data reader
•Is used to retrieve data from a data
source in a read-only and forward-only
mode.
•Stores a single row at a time in the
memory.
•Commonly used methods:
–Read()
–Close()
–NextResult()
DataAdapter
DataAdapter

 Data adapter
•Creates a dataset and updates the
database.
•Handles data transfer between the
database and the dataset through its
properties and methods.
•Displays the data through the process of
table mapping.
•Are of two types:
–SqlDataAdapter
–OleDbDataAdapter
DataSet
DataSet Object Model

DATASET

DataRelationCollection DataTableCollection ExtendedProperties

DataRelation
DataTable

DataRowCollection DataView PrimaryKey DataColumnCollection


DataSet
 Is present as a DataSet class in the
System.Data namespace.
 Has its own object model.
 Is a disconnected, cached set of
records that are retrieved from a
database.
Types of DataSet

 Datasets are of two types:


•Typed
•Untyped

 Typed dataset
•Is derived from the DataSet class and
has an associated XML schema, which
is created at the time of the creation of
the dataset.
•Can be customized after creation.
•Supports Intellisense and
auto‑completion for the elements of the
syntax while writing code.
Types of DataSet..
 Untyped Dataset
 Does not have any associated XML
schema, therefore, the structure of an
untyped dataset is not known at the
compile time.
 Represents tables and columns as
collections.
 Does not support Intellisense and
auto‑completion for the elements of the
syntax.
Command
Builder
DataRelation
Object
Bulk Copy
Bulk Data
ADO.NET 2.0
Features
ADO.NET 2.0 Features

 Asynchronous Processing
 Generic Coding with DB Provider
Factories
 Transaction Management
 State Management
ADO.NET 2.0
Features
Asynchronous
Processing
Synchronous with Asynchronous Calls
Async Operations in ASP.NET
Async Operations in ASP.NET
WaitAll
Wait Any
Async Implemented Methods
Common Provider
Factory
Hierarchy
System.Data.Common.DbProvider.Fa
ctory
DB Provider Factory
Transactions
DB Transactions
Transaction – Concurrency Problems
Transactions Isolation Level
Settings Isolation Level
Transactions in ASP.NET 1.1
Reset Isolation Levels
Save Point in Transactions
Transactions
Demo
Setting the Save Point
Transaction
Handling
Transaction Scope
Transactions Completed Event
Setting Isolation Level
Session State
Configuration
Session State Configuration
Session State Management
In Process Mode
State Server Mode
SQL Server Mode
Disabling Session State
Demo
Session Ends
Exercise
Relax

You might also like