Skip to main content

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 control in windows form, we can navigate through records with the help of Binding Navigator control. So for every binding between data source and control, A binding navigator control handles the binding to the data source by keeping a pointer to the current item in record set.

The Display Member property of the controls is used to bind the control to specific data elements.

The binding navigator control is frequently used with the binding source control to enable users to navigate through data records on a form and interacts with records.

The binding navigator source control provides a layer of interaction between controls of windows form and data source to navigate and modify the data in windows form.

Filtering Data
To display only selective records, filter the data so that only display the desired output. We can also sort the data to display it in ascending or descending order. There are two methods for filtering the data.

By Parametric Queries:
By using parametric queries, data can be filtered based on criterion entered by a user at run time.

Parameterized queries can be used in any situation where you need database operation to be executed on SQL server.

We need to create SqlParameter object to assign the parameterized values to SQL server queries and then execute the command on our desired connection.

Stored Procedure provide the benefits of precompiled execution, reduced network traffic, efficient reuse of code, and enhanced security measure for the data stored in database.

Filter Data Using Controls of a Windows Form
With the help of controls in a windows form data can be filtered to view selective records.

Data Table
A data table is a collection of columns rows and constraints. A data table object is declared to perform disconnected data access.

Data View
A data view control creates a customized view of the data stored in a database. In addition to Fill By Tool Strip control, you can also filter the data using the data view control of a windows form. Fill By Tool Strip and data view control in windows form selective records.

Connected and Disconnected Environment
In Connected Environment, a user or an application is constantly connected to data source.

Advantage of Connected environment:
Data concurrency issues are easier to control. If a user connected to data source and he modifies something in data another user cannot modify the data unless the first user completed the modification. Data is concurrent and updated.

Disadvantage of Connected Environment:
A constant network may lead to network traffic problems scalability and performance issues in application. It slows the query processing.

In disconnected environment, a user is not directly connected to data source connected to only retrieve data. After data is retrieve, the connection with the data source is closed. When the data needs to be updated, the connection is re-established.

Advantage of Disconnected Environment:
Allow the multiple application to simultaneously interact with the data source. Improve the scalability and performance of application.

Disadvantage of Disconnected Environment:
Data is not always updated as no connection is established with the data source. Data concurrency issues can occur when multiple users are updating the data to the data source.

ADO.NET class hierarchy can be categorized as disconnected classes and connected classes.

Working with Connected Environment:
In connected environment, a data reader object is used.
A DataReader object, which is component of data provider uses the connection object to connect to the database and then uses the command object to retrieve data and provides data to the application in a read only and forward only mode.

Command object is used to manipulate data in a data source. It represents a DML statements or Stored Procedure that is used to retrieve, insert delete modify data in a data source.

A data command is an instance of the OleDBCommand or SqlCommand classes.

There are two types of operations performed by a command object to retrieve and modify data are Synchronous operation and asynchronous operations.

Synchronous Operations:
In synchronous operations, the command objects are linked to each other. Sequential execution, where each database command must complete before the next command is executed.

Synchronous operation are performed by DbCommand object, DbParameter object, DbDataReader object.

Asynchronous Operations:
In asynchronous operations, the command executes without waiting for the command execution to finish which can be very handly in situations where you are trying to executes long running database command from a windows application.

Asynchronous execution enhances the overall performance of client application.

ADO.NET supports asynchronous execution of commands to enable parallelism by allowing the client application to execute commands while waiting for the previous command.

Asynchronous operation is done by SqlCommand class provides various methods for asynchronous execution of commands.

Comments

Popular posts from this blog

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 ...

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 . Read  :  How To Create Connection with Database in SQL Read  :  What is ADO.NET? Read   :   D ata Table and Data View in ADO.NET 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 ...