Data Adapter and Data Set in ADO.NET
Data Adapter:
DataAdapter is a part of the connected environment. A DataAdapter
is integral to the working of ADO.NET because of data is transferred to and
from a database through a DataAdapter.
A DataAdapter
retrieves data from a database and store into a DataSet.
When you make
changes to DataSet the changes in the database are actually done by the DataAdapter.
The DataAdapter
first compares the data in the DataSet with that in the database
and then updates the database.
DataAdapter that can be configured to connect to a
database in visual studio NET.
A DataAdapter
uses the connection objects SqlConnection, OleDbConnection, OdbcConnection,
OracleConnection
to communicate with the database.
A DataAdapter
communicates with a database while retrieve, inserting, deleting, updating
data.
The properties and
methods of a DataAdapter can be used to perform various operation on a
database.
Table Mapping in DataAdapter:
A DataAdapter
handles data transfer between the database and the DataSet through its properties
and methods and displays data through the process of table mapping.
It is used to map
the column in the database table with the DataSet column.
When you generate a
DataSet
the columns names are same as in the database table, but you may want to change
the columns names in DataSet for better readability.
Thus. Mapping is useful.
A DataAdapter
uses the table mapping property.
A collection of
data table mapping objects is used for mapping between the database table and
data table object in the database.
There is one data
table mapping object defined for each set of mapped tables.
When the DataSet
is filled with records the DataAdapter looks each source
columns name in the table mapping object, gets the matching columns in DataSet
table, and then writs the data to the data table in the DataSet.
Persisting Changes to a Database:
Data access can be
done by more than one user anytime anywhere simultaneously.
Database looking
allows concurrent access to the database in a connected environment where multiple
users can view and modify the data at the same time.
A consisting view
of data is created by locking table rows database to prevent multiple users
from accessing inconsistent data.
Data concurrency
conflicts that arise from multiple updates performed on the database without
implementing locking.
Data concurrency
conflicts can be resolved by prioritised on time first updates wins,
prioritised on time last updates wins.
Batch Updates:
To increase the
performance of data updates is to updates and send changes to the database in
batches. This is known as batch updates.
Batch updates are
performed by using the update batch size property of the SqlDataAdapter objects.
By default, this
property is set to 1.
To confirm that the
changes are sent to the database server in batches is to add a row updated events
to the SqlDataAdapter object.
This event will
show the number of rows affected in the last batch.
When the update
batch size property is set to 1, then the record affected property will be 1.
Factory Classes:
ADO.NET provides
support for classes that can be create any provider specific objetcs as SqlClient,
ObdcClient,
OracleClient
and OleDbClient.
These classes are known as DbProvider factories classes.
The DbProvider
factories classes contain a method called GetFactoryClasses(), that returns a DataTable.
Complex Data
binding involves the following properties.
Data Source : It is a data source.
Data Members: It is data member to work with in the data
source.
DisplayMember : It is the field where we want a control to
display like a column.
ValueMember: It is the field you want the control to
return in properties.
Comments
Post a Comment