O'Reilly logo

ADO.NET in a Nutshell by Bill Hamilton, Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comments/Troubleshooting

The DataTable class provides a consistent programming model regardless of the actual data source. The DataTable contains DataColumn and Constraint objects that define the schema of the data represented. The actual data is stored as a collection of DataRows within the DataTable.

The schema of the DataTable can be created entirely programmatically, retrieved as the result of a query against a data source using a .NET managed data provider or loaded from an XML document or stream through the DataSet the DataTable belongs to.

The data in the DataTable can be populated from the data source, modified, and later reconciled back to a data source using a DataAdapter. Alternatively, the data can be populated from XML documents or streams, modified, and saved as an XML document or stream through the DataSet the DataTable belongs to. Finally, the data stored in the DataTable can be manipulated programmatically.

There are similarities between the DataTable and the DataReader in that they both can store the results of a query, which can then be accessed through row and column objects. The primary difference is that the DataTable is a disconnected class that places little restriction on how the data within it is accessed and allows that data to be filtered, sorted, and modified; the DataReader is a connected class that provides little functionality beyond forward-only, read-only access to the result set, one row at a time.

The commonly used public properties of the DataTable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required