|
.NET dataset objects - August 25, 2008 at 18:00 PM by Amit
Satpute
What is Dataset object?
Answer
Databases
|
DataProviders
|
DataAdapters
|
DataSets
The DataSet is an in-memory cache of data retrieved from a data source. It
consists of a collection of DataTable objects. These DataTables can be related
to eachother with the help of DataRelation objects.
DataSet object can not directly interact with Database. A DataAdapter object
needs to be created to refer to the connection that is
created.
What are the various objects in Dataset?
Answer
The DataSet class exists in the System.Data namespace. The Classes
contained in the DataSet class are:
DataTable
DataColumn
DataRow
Constraint
DataRelation
How to save data from dataset?
Answer
The modified data needs to be sent back to the database in order to
save it. Therefore, to send the modified data to a database, the Update method
of a TableAdapter or data adapter needs to be called. The Update method
executes either of INSERT, UPDATE, or DELETE depending on the RowState in the
table.
In Visual Studio a TableAdapterManager component is used for saving the proper
order based on the foreign-key constraints of the database.
Although the procedure to save the data may change depending upon the
applications, the following steps throw light on the generalized concept:
The code sends updates to the database should be written within a try/catch
block.
The data row should be located to determine the problem area and the code should
then be reattempted.
October 30, 2008 at 18:10 pm by Amit Satpute
Explain the difference between dataset clone and dataset copy?
Dataset.clone() duplicates (only) the structure of a dataset, without
duplicating the data.
Dataset.copy() performs a deep copy of the dataset.
Explain the difference between DataSet and DataReader
Datareader fetches one row at a time from the datasource. DataSet fetches all
data from the datasource at a time to its memory area.
Datareader is like a forward only recordset. We can traverse through an object
in a DataSet to get required data.
DataReader is readonly and can be chosen when the network connection is slow.
DataSet is always a bulky object that requires lot of memory space compare to
DataReader.
|