Creating a Dataset in Code

The ch10_01 example creates a connection to a data source, SQL Server in this case, and then binds the data from that data source to a data grid. This example uses the authors table in the pubs database, and displays that table, as you can see in Figure 10.2.

Figure 10.2. The ch10_01 example.

We'll take this example apart line by line to see what makes it tick. When the user clicks the Connect to Database button you see in Figure 10.2, this application starts by creating a new dataset object named dataset1, passing that name to the DataSet constructor (note that we're using the System.Data.SqlClient namespace here to ...

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

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