Technically part of the ADO.NET object library, the DataSet is one of the most fundamental and widely used data objects in the .NET framework. Used as an in-memory representation of database/XML data, it supports a plethora of handy methods, properties and contains various other object references for working with tables, rows, columns, relationships and more.
Because the DataSet supports so many features and contains so many references to other objects in the ADO.NET library, it can take quite some time to figure out just what is available to you as a developer when working with this object.
The DataSet object is also directly bindable as a data source on the various GUI components that support data binding. It works very nicely with the ASP.NET DataGrid object since both objects were designed to contain data in a similar tabular format.
In this tutorial we’ll focus on 3 key examples to explore some of the lesser known features of the DataSet object. The first example will be manual construction of a DataSet object from scratch. This example will get you familiar with the various object types that compose the DataSet object itself. By constructing the object from scratch you’ll have an idea of what happens when a DataSet is constructed from a database source.
The second example we’ll explore a handy object in ADO.NET that allows you to sort data in the DataSet object by using simple SQL like commands. We’ll build an example that sorts one of the columns of our DataSet from ascending to descending through auto-detection.
In the final example we’ll see how we can index our DataSet by creating a primary key, which then allows us to search through our DataSet for specific rows matching the values on the index we created.
Note: This example requires Visual Studio .NET with ASP.NET 1.1 capability. Both VB.NET and C# code samples will be provided
Read More