Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 18 Getting Started with ADO .NET 453


program, and that each dataset contains only a subset of the tables and fields within your
entire database file; that is, only the items that you selected while using the Data Source
Configuration Wizard. The dataset is displayed in a hierarchical (tree) view in the Data
Sources window, with a root node for each of the objects that you selected in the wizard.
Each time you run the wizard to create a new dataset, a new dataset tree is added to the
Data Sources window, giving you potential access to a wide range of data sources and views
within a single program.

If you have been following the instructions for selecting fields in the Faculty table of the
Faculty2010 database, you have something interesting to display in the Data Sources window
now. To prepare for the following exercises and display the Data Sources window, display the
form again (click the Form1 .vb [Design] tab), and then click the Show Data Sources command
on the Data menu. (You can also click the Data Sources tab if it is visible .) When the Data
Sources window is open, expand the Faculty table so that you can see the two fields that we
selected. Your Data Sources window looks like this:

Across the top of the window are four helpful tools that allow you to work with datasets.
From left to right, these toolbar buttons allow you to add a new dataset to your project, edit
the selected dataset in the Dataset Designer, add or remove dataset fields, and refresh the
dataset.

The easiest way to display the information in a dataset on a form (and therefore for your
users) is to drag objects from the Data Sources window to the Windows Forms Designer.
(This is the Designer you used in earlier chapters, but I am calling it the Windows Forms
Designer here to distinguish it from the Dataset Designer .)

Chapter 19, “Data Presentation Using the DataGridView Control,” describes how you can
display entire tables of data on a form. In the remainder of this chapter, however, you’ll
experiment with dragging individual fields of data to the Windows Forms Designer to bind
controls to select fields in the Faculty2010 database. Give it a try now.
Free download pdf