You are on page 1of 5

Hari K Reddy Asp.

net 1

ADO.NET Basic Concept

An Introduction to ADO.NET

In today’s world, businesses applications need to manage voluminous data or


information. Data is generally stored in a relational database in the form of database
object’s tables. Retrieving and manipulating the data directly to the database requires
sound knowledge of SQL query (Database Command to access the data from the Database
tables).
Most of the business applications allow user to retrieve the information or data, which are
stored in a database and present it in a User-friendly interface with out having to write
database commands. The users can Insert /Update /Delete/Search data (records) directly
from the GUI (Graphical User Interface) based application (WEB/WINDOWS).

Technical Introduction of ADO.NET

ADO.NET is an object-oriented set of libraries that allows you to interact with data
sources. Commonly, the data source is a database, but it could also be a text file, an Excel
spread sheet, or an XML file.
As you are probably aware, there are many different types of databases available. For
example, there is Microsoft SQL Server, Microsoft Access, Oracle, Borland Interbase, and
IBM DB2, just to name a few.

Features of ADO.NET
Some of the key features of ADO.NET are given bellow:

Disconnected data Architecture


ADO.NET uses disconnected data architecture. Applications connect to the database
only while retrieving and updating data. After the data are retrieved, the

Connection with the original data source (Database) is closed. When the database needs to
be updated then the connection re-established.

Data Cached in a dataset


In ADO.NET Dataset is the most common method of accessing the data from the
database. As because ADO.NET is based on Disconnected architecture that’s why all records
are cached (or Stored) in a dataset object.

Scalability
Any database operations (Such as INSERT/UPDATE/DELETE/SEARCH) are performed
on the dataset instead of on the database for this reason memory resources are saved.

Data transfer to XML is very easy


You can transfer Dataset’s data into the XML format very easily (XML is standard for
all language and different operating systems).

ADO.NET object Model


Hari K Reddy Asp.net 2

Data Provider

Accessing
Retrieving
Data CONNECTION
Visual Basic
.NET
Application
(Windows DATA READER
/Web)
DATA BASE
Accessing Retrieving Data
COMMAND

DATASET
DATA ADAPTER
Filling
dataset
with Data

The ADO.NET Object


Model

The information or Data are stored in the Database (SQL Server /Oracle/DB2 etc). The data
are being retrieving from the database using ADO. Net’s data Provider.

Note:
A .NET application can access data either through data set or through Data Reader
object.

Data Provider and Dataset these two are key components of ADO.NET.

Data Provider
A data provider is used for connecting to the database, retrieving data, storing the
data in a dataset, reading the retrieved data and updating the database.
There are main two types of data providers:
• OLEDB Data Provider---
This type of data provider works with all OLE DB providers, such as
SQL IOLE DB provider, Oracle OLE DB provider, and Jet OLE DB provider. The
OLE DB provider classes are present in the System.Data.OleDb namespace.

• SQL Server data provider—


This type of data provider is used to work specifically with Microsoft
SQL Server. A SQL Server data provider is recommended for working with a
Microsoft SQL Server data source, since a SQL Server data provider allows
fast access to the data from the SQL Server data source. The SQL Server data
provider classes are present in the System.Data.SqlClient namespace.
Hari K Reddy Asp.net 3

Details Description Of Data Provider:

The various components of ADO. Net’s data providers are discussed bellow:
• Connection---
This component is used to establish the connection between the data
source with the .NET application (Window/ Web). Commonly used methods
and properties of Connection object these are
ConnectionString, State main properties
Open (), Close () main methods
• Data Adapter---
A data adapter is integral to the working of ADO.NET since data is
transferred to and from database through a Data Adapter. The data adapter
retrieve data from the database into dataset. When you make changes to the
dataset, and these changes in the database actually done by the Data
Adapter. Data adapter compares the data in the dataset then reflects the
changes in the original data source. Mainly two types of data adapters are
used in the. NET application
SqlDataAdapter and OleDbDataAdapter

A data adapter uses the connection objects (SqlConnection) provided by the


data provider to communicate with the database.
Data adapter handles data transfer between the database and the dataset
through its properties and methods and displays data through the process of
table mapping. Some important properties and methods are given bellow:
SelectCommand, InsertCommand, UpdateCommand, DeleteCommand,
Fill (), Update ()

• Data Command---
A data Command is an object representing a SQL statement or stored
procedure that is used to retrieve, insert, delete or modify data in a data
source. A data command is an object of the OleDbCommand or SQLCommand
class. A data command derived from the OleDbCommand class.

• Data Reader--
Data Reader is used to retrieve data from the database in a read-only
and frwd-only mode. A data reader uses the Connection object to connect to
the database, the Command object to execute SQL Statement or procedures
on the database and retrieves the data in a sequential mode.

Difference between viewstate, cache, session.

SESSION: Variables are stored on the server, can hold any type of data including
references, they are similar to global variables in a windows application and use HTTP
cookies to store a key with which to locate user's session variables.

VIEWSTATE: Variables are stored in the browser (not as cookies) but in a hidden field in
the browser. Also Viewstate can hold only string data or serializable objects.
Hari K Reddy Asp.net 4

CACHE: It refers to information that is reused in your application, or information that is


stored on your computer so it can be reused. For example, if you download an image from
the internet, it's often cached so you can view it again without downloading the image data.
Caching is a form of replication in which information learned during a previous transaction is
used to process later transactions.

How will you mange sessions in asp.net?

ASP.NET Session Management Alternatives:


ASP.NET provides three modes of session state storage controlled by mode attribute of
<sessionState> tag in your web application’s Web.config file.
<sessionState mode="InProc" sqlConnectionString="data
stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false"
source=127.0.0.1;Trusted_Connection=yes" timeout="20" />
Attribute Option Description
mode Specifies where to store the session state.
Off Disables session state management.
Session state is stored locally in memory of ASP.NET worker
InProc
process.
Session state is stored outside ASP.NET worker process and is
StateServer managed by Windows service. Location of this service is specified
by stateConnectionString attribute.
Session state is stored outside ASP.NET worker process in SQL
SQLServer Server database. Location of this database is represented by
sqlConnectionString attribute.

What is the use of ConnectionConsumer attribute in asp.net?

It says that it is a receiver and it receives the message from the provider.

When to Use Interfaces

An interface allows somebody to start from scratch to implement your interface or


implement your interface in some other code whose original or primary purpose was quite
different from your interface. To them, your interface is only incidental, something that
have to add on to their code to be able to use your package.

When to Use Abstract classes


Hari K Reddy Asp.net 5

An abstract class, in contrast, provides more structure. It usually defines some default
implementations and provides some tools useful for a full implementation. The catch is,
code using it must use your class as the base. That may be highly inconvenient if the other
programmers wanting to use your package have already developed their own class
hierarchy independently. In Java, a class can inherit from only one base class.

You might also like