嗨,我正在尝试创建一个循环以从数据库中提取数据。我目前拥有的代码无法正常工作,我不确定是否可以完成。 这是代码
'TODO:这行代码将数据加载到'NewFixedDBDataSetJustTest.FIxLastTime'表中。您可以根据需要移动或删除它。 'Me.FIxLastTimeTableAdapter.Fill(Me.NewFixedDBDataSetJustTest.FIxLastTime) Me.FIxLastTimeTableAdapter.FillByBetweenDates(Me.NewFixedDBDataSetJustTest.FIxLastTime,“ 01/12/2005”,“ 30/12/2005”)
Dim index As Integer = 0
Dim Pred As String = Nothing
Dim Pred1 As String = "Rat"
Dim Pred2 As String = "Cat"
Dim Pred3 As String = "Ferret"
Do
Dim FerretsGone9 As Integer
Dim CatsGone9 As Integer
Dim RatsGone9 As Integer
For Each row As DataGridViewRow In FIxLastTimeDataGridView.Rows
If row.Cells(1).FormattedValue = Pred(index) Then
RatsGone9 += row.Cells(2).Value
CatsGone9 += row.Cells(2).Value
FerretsGone9 += row.Cells(2).Value
End If
Next
lbCats.Text = CatsGone9
lblRats.Text = RatsGone9
lblFerrets.Text = FerretsGone9
index += 1
Loop Until index = 3
End Sub