16. What is the role of the DataSet object in ADO.NET?
One of the major component of ADO.NET is the DataSet object, which always remains disconnected from the database and reduces the load on the database.
17. What is a DataReader object?
The DataReader object helps in retrieving the data from a database in a forward-only, read-only mode. The base class for all the DataReader objects is the DbDataReader class.
The DataReader object is returned as a result of calling the ExecuteReader() method of the Command object. The DataReader object enables faster retrieval of data from databases and enhances the performance of .NET applications by providing rapid data access speed. However, it is less preferred as compared to theDataAdapter object because the DataReader object needs an Open connection till it completes reading all the rows of the specified table.
An Open connection to read data from large tables consumes most of the system resources. When multiple client applications simultaneously access a database by using the DataReader object, the performance of data retrieval and other related processes is substantially reduced. In such a case, the database might refuse connections to other .NET applications until other clients free the resources.
One of the major component of ADO.NET is the DataSet object, which always remains disconnected from the database and reduces the load on the database.
17. What is a DataReader object?
The DataReader object helps in retrieving the data from a database in a forward-only, read-only mode. The base class for all the DataReader objects is the DbDataReader class.
The DataReader object is returned as a result of calling the ExecuteReader() method of the Command object. The DataReader object enables faster retrieval of data from databases and enhances the performance of .NET applications by providing rapid data access speed. However, it is less preferred as compared to theDataAdapter object because the DataReader object needs an Open connection till it completes reading all the rows of the specified table.
An Open connection to read data from large tables consumes most of the system resources. When multiple client applications simultaneously access a database by using the DataReader object, the performance of data retrieval and other related processes is substantially reduced. In such a case, the database might refuse connections to other .NET applications until other clients free the resources.
18. What is the use of the Connection object?
The Connection object is used to connect your application to a specific data source by providing the required authentication information in connection string. The connection object is used according to the type of the data source. For example, the OleDbConnection object is used with an OLE-DB provider and the SqlConnectionobject is used with an MS SQL Server. |
|
19. How can you identify whether or not any changes are made to the DataSet object since it was last loaded?
The DataSet object provides the following two methods to track down the changes: The GetChanges() method - Returns the DataSet object, which is changed since it was loaded or since the AcceptChanges() method was executed. The HasChanges() method - Indicates if any changes occurred since the DataSet object was loaded or after a call to the AcceptChanges() method was made. If you want to revert all changes since the DataSet object was loaded, use the RejectChanges() method.
20. What is the use of the CommandBuilder class?
The CommandBuilder class is used to automatically update a database according to the changes made in aDataSet.
This class automatically registers itself as an event listener to the RowUpdating event. Whenever data inside a row changes, the object of the CommandBuilder class automatically generates an SQL statement and uses theSelectCommand property to commit the changes made in DataSet.
OLEDB provider in .NET Framework has the OleDbCommandBuiider class; whereas, the SQL provider has theSqlCommandBuilder class.
The DataSet object provides the following two methods to track down the changes: The GetChanges() method - Returns the DataSet object, which is changed since it was loaded or since the AcceptChanges() method was executed. The HasChanges() method - Indicates if any changes occurred since the DataSet object was loaded or after a call to the AcceptChanges() method was made. If you want to revert all changes since the DataSet object was loaded, use the RejectChanges() method.
20. What is the use of the CommandBuilder class?
The CommandBuilder class is used to automatically update a database according to the changes made in aDataSet.
This class automatically registers itself as an event listener to the RowUpdating event. Whenever data inside a row changes, the object of the CommandBuilder class automatically generates an SQL statement and uses theSelectCommand property to commit the changes made in DataSet.
OLEDB provider in .NET Framework has the OleDbCommandBuiider class; whereas, the SQL provider has theSqlCommandBuilder class.