我收到此错误:没有数据时无效尝试。它说第39行和第198行是导致此错误的原因
第39行
Sub loadstudent()
lvstudent.Items.Clear()
While RD.Read
With lvstudent.Items.Add(RD(1), 0)
.SubItems.Add(RD(5)) '48
.SubItems.Add(RD(0))
End With
End While
End Sub
第198行:
sSql = "Select * from tblstudentprof where status='ACTIVE' "
execSQL(sSql, False)
loadstudent()
我还使用循环来计算列表视图中的所选项目并将其移动到连接到第148行和第39行的tblstudentprof。
Private Sub btnmove_Click(sender As Object, e As EventArgs) Handles btnmove.Click
Dim ctr, count, minus As Integer
ctr = lvstudent.Items.Count - 1
While ctr >= 0
If lvstudent.Items(ctr).Checked = True Then
sSql1 = "Update tblstudentprof set secid='" & txtsecid.Text & "',yrlevelid='" & txtyrlevelid.Text & _
"',remarks='ENLISTED' where studid ='" & lvstudent.Items(ctr).SubItems(2).Text & "'"
execSQL1(sSql1, True)
ctr -= 1
End If
End While
count = lvstudent.Items.Count
minus = count - ctr1
If minus > 0 Then
MsgBox("There is/are " & minus & "updated students sections.")
Else
MsgBox("Successfully updated students sections.")
End If