Skip to main content

Data Adapter and Data Set in ADO.NET

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

Popular posts from this blog

ADO.NET Framework | Data Binding | Data Table | Data View | Connected and Disconnected Architecture

ADO.NET Framework | Data Binding | Data Table | Data View | Connected and Disconnected Architecture Data Binding Data binding is the ability to bind some elements of a Data Source with the controls of an application. Read : How To Create Connection with Database in SQL Read  :  What is ADO.NET? On the basis of the number of bound, there are two types of binding: Simple Data Binding: Simple Data Binding is the process of binding a control to a single value in DataSet . The DataSet values can be bound to the control by using the properties of the control. Complex Data Binding Complex Data Binding is the process of binding a component (Data Grid View, List Box, and Combo Box) to display multiple values from DataSet .  Complex data binding is the ability to bind a control to more than one record to a data source. The data source property of the control is used to bind the control to a database. Navigation Between Records After binding to...

How To Create Connection With Database in SQL Server

How To Create Connection With Database in SQL Server Creating and Managing Connections To connect to a database for retrieving the data and updating the database, performs the following tasks. 1.     Create a connection object 2.     Create a command object 3.     Open the Connection object, 4.     Execute SQL statements in command object 5.     Close the connection object Creating a CONNECTION object: The connection component of a data providers is used to establish a connection with a Data Source. Read : What is ADO.NET?   To create a connection between User Interface and Data Source, Create a connection object. Read:  Connected and Disconnected Architecture of ADO.NET Use SqlConnection class to open the connection of Microsoft SQL Server Database . After creating the connection object, Use ConnectionString property provides the ...