Dataprovider Datareader: Oledb Oledbdatareade SQL Sqldatareader Odbc Odbcdatareader
Dataprovider Datareader: Oledb Oledbdatareade SQL Sqldatareader Odbc Odbcdatareader
OleDb OleDbDataReade
Sql SqlDataReader
ODBC ODBCDataReader
Q #12) What is Databinding?
Answer: Databinding is the process of binding the data with graphical elements (controls in
a window form). After binding the data in a window form, you can navigate through the
records with the help of the Binding Navigator Control.
One of the advantages of data binding is, the user does not need to write the codes
explicitly, for establishing the connections and creating a data set, this feature will write the
necessary ADO.NET code for the user.
(ii) To Close a connection properly, refer the below figure. The connection is automatically
closed at the end of ‘using’ block.
Q #5) Give an example of a .NET application which connects to Microsoft Access
Database using Ado.net classes.
Answer: Example given below describes only how to establish a connection to Microsoft
Access Database, it won’t explain about the executing commands against the database.
Please refer the below figure:
For establishing a connection to the database and retrieve the values from a database
we need to follow the below steps:
Import reference library class. Example: using System.Data.OleDB.
Create a connection object.
Specify the connection string, you may copy that from the Database Property.
Use Connection object constructor and specify the ‘connection String ‘as Argument.
Open an instance of Connection (It’s better to open it in a try-catch statement).
Q #6) What is Connection Pooling?
Answer: Data providers implement ‘Connection pooling’ services. ‘Connection pooling’
improves performance. Connection pooling creates a set of connections.
When you are establishing a connection with the database, you will be given a connection
from a pool. When you disconnect from the database, the connection will return to the pool
and that connection will be used by the next applicant who wants a connection.
With ‘Connection pooling’ the ‘opening’ and ‘closing’ of connections no longer become an
expensive task.
Disconnected Environment
Connected Environment
It requires a constant connection to transfer data between the It doesn’t require a constant connection to transfer da
application and database the application and database
Data is up-to-date since user is always connected to the Data is not up-to-date since user is always connected
database database
It has scalability and performance issues for the client It improves scalability and performance of the client
application
Untyped Dataset: Untyped dataset doesn’t have an XML schema associated with it.
Untyped Dataset, the tables, and columns are represented as a collection.
Q #22) What are the rules to implement connection pooling?
Answer: To establish a connection pooling, the following rules must be followed:
The connection string must be the same for every User.
The UserID must be the same for every user.
Q #23) What is a Datatable?
Answer: Datatable is a collection of rows, columns, and constraints. A Datatable is able to
perform disconnected data access.
Q #24) What is DataView?
Answer: A DataView control creates a customized view of data stored in Datatable. The
changes in DataView will affect the Datatable. By default, every table has a data view
attached to it.
You can then add the DataView control and bind it to a Windows form. It allows the user to
filter, navigate and sort the data in it.
Q #25) What are the major challenges in accessing data from a database?
Answer: The challenges include:
More than one user might need to access the data simultaneously from one
database.
More than one user might need to access the data anytime, anywhere.
The solution to this problem is attained by implementing a ‘Database locking’ during the
time of transaction execution.
Q #26) What is meant by ‘Transaction’ in a database and what are the ‘Properties of
Transaction’?
Answer: Transaction can be defined as a series of operations. If the transaction is
successful, all the data modifications performed in the database will be committed and
saved.
Properties of Transaction
Atomicity
Consistency
Isolation
Durability
a) Atomicity: Consider a bank transaction in which an amount, say Rs 1000/- is withdrawn
from the Account ’AB’.
If a system failure occurs, the amount will be rollbacked to the Account ’AB’ itself. This
property is termed as ‘Atomicity’. This property states that either all the changes to the data
are performed or none of them are performed.
This means that the transactions should be completed successfully or transactions should
not begin at all.
As per the above Example, the transaction will be rolled back to add Rs 500/- to Account ‘A’
and thus maintain system consistency.
d) Durability: Here it states that any change made in the data by a successful transaction
will be permanent. Recovery management system is responsible to maintain the durability of
a system.
Q #27) What are two types of transactions supported by ADO.net?
Answer:
Two types of Transaction supported by ADO.net
Local Transaction: A local transaction is based on a single data source. It will be
handled directly by the database. For Example, We import ‘System.Data.SQL client’
namespace, if we need to perform data transaction using Sqlserver. Similarly, we
import ‘System.Data.Oracle client’ namespace, if we are using Oracle database.
Distributed Transaction: If the user needs to perform a transaction across multiple
data Servers like SQL Server, Oracle, etc he can use a distributed transaction.
Q #28) What is the difference between DataReader and DataSet?
Answer: Differences are as follows:
DataReader DataSet