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.
18 Appendix H Using <strong>ADO</strong>.<strong>NET</strong> <strong>2.0</strong> <strong>with</strong> <strong>Microsoft</strong> <strong>Access</strong> <strong>Databases</strong><br />
Examples<br />
TblEmployBindingSource.MoveFirst()<br />
moves the record pointer to the first record in the dataset<br />
TblEmployBindingSource.MoveLast()<br />
moves the record pointer to the last record in the dataset<br />
TblEmployBindingSource.MoveNext()<br />
moves the record pointer to the next record in the dataset<br />
TblEmployBindingSource.MovePrevious()<br />
moves the record pointer to the previous record in the dataset<br />
Moves the record<br />
pointer to the next<br />
record in the<br />
dataset<br />
Moves the record<br />
pointer to the<br />
previous record in<br />
the dataset<br />
Visual Basic code<br />
FIGURE H.22<br />
When the Next button in the Morgan Industries application is clicked, its<br />
Click event procedure should move the record pointer to the next record in the<br />
dataset. Similarly, when the Previous button is clicked, its Click event procedure<br />
should move the record pointer to the previous record in the dataset. You can<br />
use the TblEmployBindingSource object’s MoveNext and MovePrevious methods<br />
to code the procedures, as shown in Figure H.23.<br />
Private Sub nextButton_Click(ByVal sender As Object, _<br />
ByVal e As System.EventArgs) Handles nextButton.Click<br />
TblEmployBindingSource.MoveNext()<br />
End Sub<br />
Private Sub previousButton_Click(ByVal sender As Object, _<br />
ByVal e As System.EventArgs) Handles previousButton.Click<br />
TblEmployBindingSource.MovePrevious()<br />
End Sub<br />
FIGURE H.23<br />
How to use the BindingSource object’s Move methods<br />
Code entered in the Next and Previous buttons’ Click<br />
event procedures<br />
Appendix H C5779 39147 Page 18 07/10/06--JHR<br />
DATASET DESIGNER<br />
As you learned earlier, data stored in a relational database can be displayed in<br />
any order. For example, you can arrange the data contained in the Employees<br />
database by employee number, pay rate, status, and so on. A relational database<br />
also allows you to control the amount of information you want to view at a<br />
time. You can view all of the information in the Employees database, or you can<br />
view only the employee numbers and corresponding pay rates. You also can<br />
choose to view only the records for the part-time employees.