Filling Datasets with Local Data

In our first example, ch10_01, we accessed the data in the authors table in the pubs example database on SQL Server. But you don't have to connect to an external data source. You can fill a dataset locally, with entirely local data—no external data connection needed.

We're going to create our own database table in this example and store that table in a dataset. You can see this new example, ch10_02 in the code for this book, at work in Figure 10.3, where the data grid is displaying data for a set of customers that we've stored in a data table, which itself is stored in a dataset.

Figure 10.3. The ch10_02 example.

To make this work, we'll start with a look at the DataTable class.

Working with the DataTable Class ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.