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?
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.
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
Post a Comment