HUsing ADO.NET 2.0 with Microsoft Access Databases - Cengage ...
HUsing ADO.NET 2.0 with Microsoft Access Databases - Cengage ...
HUsing ADO.NET 2.0 with Microsoft Access Databases - Cengage ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Binding the Objects in a Dataset 11<br />
DataSet<br />
TableAdapter<br />
BindingSource<br />
Database<br />
Bound controls<br />
on the form<br />
Appendix H C5779 39147 Page 11 07/10/06--JHR<br />
The DataSet, BindingSource,<br />
and TableAdapter objects, as<br />
well as the Timer control you<br />
learned about in Chapter 2,<br />
are examples of objects that<br />
appear in the component tray<br />
during design time, but are not<br />
visible during run time.<br />
FIGURE H.14<br />
Illustration of the relationships among the database, the<br />
objects in the component tray, and the controls on the form<br />
The TableAdapter object connects the database to the DataSet object,<br />
which stores the information you want to access from the database. The<br />
TableAdapter is responsible for retrieving the appropriate information from<br />
the database and storing it in the DataSet. It also is responsible for saving to the<br />
database any changes made to the data contained in the DataSet.<br />
The BindingSource object provides the connection between the DataSet<br />
object and the bound controls on the form. For example, the<br />
TblEmployBindingSource object (shown earlier in Figure H.13) connects the<br />
EmployeesDataSet object to two bound controls: the DataGridView control and<br />
the BindingNavigator control. The BindingSource object allows the DataGridView<br />
control to display the data contained in the dataset. It also allows the<br />
BindingNavigator control to access the records stored in the dataset.<br />
If a table object’s control type is changed from DataGridView to Details, the<br />
computer automatically provides the appropriate controls (such as text boxes,<br />
labels, and so on) when you drag the table object to the form. It also adds the<br />
BindingNavigator control to the form, and adds the DataSet, BindingSource,<br />
TableAdapter, and BindingNavigator objects to the component tray. The appropriate<br />
controls and objects are also automatically included when you drag a field<br />
object to an empty area on the form.<br />
When a table or field object is dragged to the form, the computer not only<br />
adds the appropriate controls and objects to the application, but it also enters<br />
some code in the Code Editor window. Figure H.15 shows the code that is automatically<br />
entered in the Code Editor window when the tblEmploy object is<br />
dragged to the form.