JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Adding Multiple Tables to a Dataset

A single dataset can contain multiple tables. You can see how this works in the MultiTable example on the CD-ROM. In this case, I've added two SqlDataAdapter controls to the main form, and connected one to the authors table in the SQL Server pubs database, and the second to the publishers table in the same database. Now when I create a dataset (using the Data|Generate Dataset item menu item), I add both those tables to the dataset, as you see in the Generate Dataset dialog in Figure 20.29.

Figure 20.29: Using multiple tables.

That's all it takes; that's the way to add both tables to the same dataset. Now I can bind two data grids to the same dataset, displaying a different table in each data grid. (After setting the data grids' DataSource property to the new dataset, I've set the DataMember property of the first data grid to authors and the DataMember property of the second data grid to publishers.) You can see the result in Figure 20.30.

Figure 20.30: Working with multiple tables from the same dataset.

Related solution:

Found on page:

Creating a Data Table in Code


Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor