|
Navigating through the records Private Sub btnNext_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnNext.Click
currRec += 1
If currRec >= totalRec Then
currRec = 0
End If
FillControls()
End SubWe first increment the integer variable currRec and check if
it has crossed the last record (using the totalRec variable) in the table.
If it has, then we move the current record to the first record. We then
call the FillControls() method to display the current record on the form.
Similarly the event for the "Previous" button looks like this: Private Sub btnPrevious_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnPrevious.Click
currRec -= 1
If currRec < totalRec Then
currRec = totalRec - 1
End If
FillControls()
End SubHere we decrement the currRec variable and check if has
crossed the first record and if it has then we move to the last record.
Once again, we call the FillControls() method to display the current
record.
You can now navigate through the records using the Next and Previous buttons.
Updating the table Please note that for this section, we will only use the "Article" table and will not be using the "Author" table for the sake of simplicity. Steps for updating the table
Again for simplicity we haven't included the steps for data validation, which is a key part of a data update in a "live" application. Building the Application
In this application, we have defined several database access objects (like SqlDataAdapter, DataSet) as private class members so that we can access them in different methods. Public Class ADOForm
Inherits System.Windows.Forms.Form
' Private global members to be used in various methods
Private conn As SqlConnection
Private conn As SqlConnection
Private ds As DataSet
Private dataTable As dataTable
Private currRec As Integer = 0
Private totalRec As Integer = 0
Private insertSelected As Boolean
...
|
|
|