请看下面的代码并告诉我为什么它没有移动到下一条记录?我以编程方式加载数据并在数据集中填写表格。我可以通过向导做到这一点,但我想用我自己的代码做到这一点;因为使用向导有时无助于理解其背后的真实代码。
Private Sub frmSystemOptions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
dsOptions = New DataSet
loadOptions()
bsInstitute = New BindingSource(dsOptions, "institute")
bnInstitute = New BindingNavigator(bsInstitute)
InstIdTextBox.DataBindings.Add("Text", dsOptions.Tables("institute"),"instId")
CodeTextBox.DataBindings.Add("Text", dsOptions.Tables("institute"), "code")
NameTextBox.DataBindings.Add("Text", dsOptions.Tables("institute"), "name")
TypeTextBox.DataBindings.Add("Text", dsOptions.Tables("institute"), "type")
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
Sub loadOptions()
Dim sql As String
Try
sqlConn = New SqlConnection(connString)
sqlConn.Open()
sql = "select * from institute"
daAdapter = New SqlDataAdapter(sql, sqlConn)
daAdapter.Fill(dsOptions, "institute")
'----------------------------------------------------------------------
sqlConn.Close()
Catch ex As Exception
sqlConn.Close()
MsgBox(Err.Description)
End Try
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If bsInstitute.Position + 1 < bsInstitute.Count Then
bsInstitute.MoveNext()
Else
bsInstitute.MoveFirst()
End If
Me.Validate()
End Sub