30.12.2013 Views

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 ...

SHOW MORE
SHOW LESS

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 15<br />

Emp_Number field object<br />

Existing numberLabel control<br />

BindingSource object<br />

Appendix H C5779 39147 Page 15 07/10/06--JHR<br />

DataSet object<br />

TableAdapter object<br />

FIGURE H.18<br />

Result of dragging field objects to existing label controls<br />

in the Morgan Industries application<br />

In addition to binding the field objects to the appropriate controls, the computer<br />

also adds the DataSet, BindingSource, and TableAdapter objects to the<br />

component tray. However, notice that it does not include the BindingNavigator<br />

object and BindingNavigator control in the application. You can use the<br />

BindingNavigator tool in the Toolbox to add a BindingNavigator control to the<br />

form; doing this also adds a BindingNavigator object to the component tray. You<br />

then must set the BindingNavigator control’s DataSource property to the name<br />

of the BindingSource object in the application. In this case, for example, you<br />

would set the control’s DataSource property to TblEmployBindingSource.<br />

Figure H.19 shows the code that is automatically entered in the Code Editor<br />

window when you drag an object from the Data Sources window to an existing<br />

control on the form.<br />

Visual Basic code<br />

' Project name:<br />

' Project purpose:<br />

'<br />

' Created/revised by:<br />

Morgan Industries Project<br />

The project displays the employee<br />

records stored in a database.<br />

on <br />

Option Explicit On<br />

Option Strict On<br />

(Figure is continued on next page)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!