Part I

 
ADO.NET is designed to help developers work efficiently with multi-tier databases, across intranet or Internet scenarios. 

 

The ADO.NET object model consists of two key components as follows: 

  • Connected model (.NET Data Provider - a set of components including the Connection, Command, DataReader, and DataAdapter objects)
  • Disconnected model (DataSet). 

ADOObjects.gif

DataSet

 

The DataSet Object is the parent object to most of the other objects in the System.Data namespace. The dataset is a disconnected, in-memory representation of data.

 

Its primary role is to store a collection of DataTables and the relations and constraints between those DataTables.

 

DataSet also contains several methods for reading and writing XML, as well as merging other DataSets, DataTables and DataRows.

 

Some of the advantages of the new DataSet object are: 

  • Read / Write
  • Connectionless
  • Contains one or more DataTable objects with relationships defined in a collection of DataRelation objects
  • Supports filtering and sorting
  • The contained DataView object can be bound to data-aware forms controls
  • Supports automatic XML serialization (creation of XML document)

DataTable

 

DataTable stores a table of information, typically retrieved from a data source. DataTable allows you to examine the actual rows of a DataSet through rows and columns collections.

 

Once the DataTable is filled the database connection is released and operates disconnected only. 

 

You can complex-bind a control to the information contained in a data table. Controls like DataGrid are used for this purpose

 

DataTable also stores metatable information such as the primary key and constraints.

 

DataRows

 

The DataRow class permits you to reference a specific row of data in a DataTable. This is the class that permits you to edit, accept, or reject changes to the individual DataColumns of the row.

You would use a DataRow object and its properties and methods to retrieve and evaluate the values in a DataTable object.

 

The DataRowCollection represents the actual DataRow objects that are in the DataTable object, and the DataColumnCollection contains the DataColumn objects that describe the schema of the DataTable object.

 

DataColumns

 

DataColumns is the building block of the DataTable. A number of such objects make up a table. Each DataColumn object has a DataType property that determines the kind of data that the column is holding. data table

 

DataColumn instances are also the class of object that you use to read and write individual columns of a database. The Items property of a DataRow returns a DataColumn.

 

DataView

 

A DataView is an object that provides a custom view of data in a DataTable. DataViews provide sorting, filtering, and other types of customizations.

 

Each DataTable object has a DefaultView property, which holds the default DataView object for that DataTable. Modifying the DefaultView object sets the default display characteristics for the DataTable.

 

You can create an instance of a DataView and associate it with a particular DataTable in a DataSet. This permits you to have two or more different views of the same DataTable simultaneously available.

 

DataRelation

 

A DataRelation identifies that two or more of the DataTables in a DataSet contain data related in a one-to-one or one-to-many (parent-child) association. You define a relationship between two tables by adding a new DataRelation object to the DataSet's

 

Constraints

 

Each DataColumn may have multiple Constraints.  Conditions such as unique are applied through this class.  Constraint objects are maintained through the DataTables Constraints collection.

 

DataRowView

 

A DataRowView is a special object that represents a row in a DataView. Each DataView can have a different RowStateFilter, the DataRowView obtained from a DataView will contain data consistent with the DataView's RowStateFilter, providing a custom view of the data.

 

Note: See my other article on ADO.NET Objects Part I.

 

Conclusion

 

Hope the article would have helped you in understanding ADO.NET objects.

 

Your feedback and constructive contributions are welcome.  Please feel free to contact me for feedback or comments you may have about this article.

Next Recommended Readings