Unit 4 C#
Unit 4 C#
NET
ADO.NET is a module of .Net Framework which is used to establish connection between
application and data sources.
Data sources can be such as SQL Server and XML. ADO.NET consists of classes that can
be used to connect, retrieve, insert and delete data.
ADO stands for Microsoft ActiveX Data Objects. ADO.NET is one of Microsoft’s Data
Access Technologies, using which we can communicate with different data sources.
ADO.NET consists of a set of predefined classes that can be used to connect, retrieve,
insert, update, and delete data (i.e., performing CRUD operation) from data sources.
ADO.NET data providers contain classes that represent the provider's Connection, Command,
DataAdapter and DataReader objects (among others).
1.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 password-based authentication.
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.
2.Command:
The Second important component of ADO.NET Architecture is the Command Object.
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.
3.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.
Read-Only 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.
4.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 the data and we can add, update,
and delete data in a data table.
DataSet gets filled by somebody called DataAdapter.
5.DataAdapter:
The DataAdapter is one of the Components of ADO.NET which acts as a bridge
between the command object and the dataset.
6.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.
7.DataProvider
Data provider is used to connect to the database, execute commands and retrieve the
record. It is lightweight component with better performance. It also allows us to place
the data into DataSet to use it further in our application.
Data Binding
Data binding allows us to bind data objects to one or more web controls, that will show the data
automatically.
The data binding model is extensible. We can extend it with new functionality The data binding
is defined outside the source code. The data binding in ASP.NET is declarative. We define it
within the ASP.NET web page.
Data binding is the process that establishes a connection between the application UI and
business logic.
It allows you to take a Page variable, property, or an expression and insert it dynamically
into a page. In other words, it allows you to pop data into HTML elements .use it, you
add special data binding expressions into your .aspx files. These
expressions have the following format:
1. Presentation Layer
2. Business Layer
3. Data Layer
This layer is used to connect the business layer to the database or data source.
It contains methods which are used to perform operations on database like insert, delete,
update, etc.
This layer contains stored procedures which are used to query database. Hence this layer
establishes a connection with the database and performs functions on the database.