0% found this document useful (0 votes)
7 views5 pages

Unit 5

Uploaded by

Vignesh .T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Unit 5

Uploaded by

Vignesh .T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

C#.

NET UIBS

Faculty of Computer Applications

21BCA3C8L - C# and Dot Net Framework

III Semester BCA

Prepared By
Sabnam Pradhan
Professor and Faculty of Computer Applications

Dept of Computer Science


C#.NET UIBS

UNIT 5 (ADO .NET Connectivity)


ADO .NET Connectivity: Introduction to ADO.NET, ADO vs ADO.NET. Architecture: Data reader, Data
adopter, Accessing Data with ADO.NET. Programming Web Applications with Web Forms. ASP .NET
applications with ADO.NET
----------------------------------------------------------------------------------------------------------------------------------

INTRODUCTION to ADO.NET

ADO is the acronym for ActiveX Data Objects. It is an application program interface from Microsoft that
allows a programmer writing Windows applications get access to a relational or non-relational database from
both Microsoft and other database providers. ADO acts as a layer to access any data stored in a generic
manner from the application code. It eliminates the need to be knowledgeable in database implementation
and reduces the complexity of dealing with the low-level code needed to handle the data.

ADO originated from the concept of Remote Data Object (RDO) and Data Access Object (DAO) and was
first released in 1996. As one of the constituents of MDAC (Microsoft Data Access Components), ADO
together with other MDAC constituents provides a framework of components used by client applications to
access SQL, semi-structured and legacy data stores.

What Is ADO.NET?

ADO.NET is a data access technology that provides communication between relational and non-relational
systems through a common set of components. ADO.NET being a technology from Microsoft .NET
Framework, can also be described as a set of classes (a framework) to interact with data sources such as
databases and XML files. ADO.NET framework is commonly used by programmers to access and modify
data stored in relational database systems, though it can also access data in non-relational data sources. The
following are a few of the .NET applications that use ADO.NET to connect to a database, execute commands
and retrieve data from the database.

• ASP.NET Web Applications


• Console Applications
• Windows Applications.

Dept of Computer Science


C#.NET UIBS

The Architecture of ADO.NET:


The ADO.NET Architecture is comprised of 6 important components. They are as follows:
1. Connection
2. Command
3. DataReader
4. DataAdapter
5. DataSet
6. DataView
From the above components, two components are compulsory. One is the command object and the other one
is the connection object. Irrespective of the operations like Insert, Update, Delete and Select, the command
and connection object you always need. For a better understanding, please have a look at the following image.

Dept of Computer Science


C#.NET UIBS

Connection:
The first important component of ADO.NET Architecture is the Connection Object. The Connection Object is
required to connect with your backend database which can be SQL Server, Oracle, MySQL, etc. To create a
connection object, you need at least two things. The first one is where is your database located i.e. the Machine
name or IP Address or someplace where your database is located. And the second thing is the security
credentials i.e. whether it is a Windows authentication or SQL Authentication i.e. user name and
passwordbased authentication. So, the first is to create the connection object and the connection object is
required to connect the front-end application with the backend data source.

Command:
The Second important component of ADO.NET Architecture is the Command Object. When we talk about
databases like SQL Server, Oracle, MySQL, etc., we know one thing, these databases only understand SQL.
The Command Object is the component where you go and write your SQL queries. Later you take the
command object and execute it over the connection. That means using the command object, you can fetch data
or send data to the database i.e. performing the Database CRUD Operations.

Note: From the Command Object onwards, you can go in two different ways. One is you can go with the
DataSet way and the other is, you can go with the DataReader way. Which way you need to choose, basically
will depend on the situation.

DataReader:
DataReader is a read-only connection-oriented recordset that helps us to read the records only in the forward
mode. Here, you need to understand three things i.e. read-only, connection-oriented, and forward mode.
ReadOnly means using DataReader, we cannot Insert, Update, and Delete the data. Connection-Oriented
means, it always requires an active and open connection to fetch the data. Forward mode means you can always
read the next record, there is no way that you can read the previous record.

DataSet:
It is a Disconnected record set that can be browsed in both i.e. forward and backward mode. It is not read-only
i.e. you can update the data present in the data set. Actually, DataSet is a collection of DataTables that holds

Dept of Computer Science


C#.NET UIBS

the data and we can add, update, and delete data in a data table. DataSet gets filled by somebody called
DataAdapter.

DataAdapter:
The DataAdapter is one of the Components of ADO.NET which acts as a bridge between the command object
and the dataset. What the DataAdapter does is, it takes the data from the command object and fills the data set.

DataView Class
The DataView class enables us to create different views of the data stored in a DataTable. This is most often
used in data-binding applications. Using a DataView, we can expose the data in a table with different sort
orders, and you can filter the data by row state or based on a filter expression.

Dept of Computer Science

You might also like