Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ListView1.Items.Count > 0 Then
For i = ListView1.Items.Count - 1 To 0 Step -1
If ListView1.Items(i).Checked = True Then
strSQL = "DELETE FROM tbl_hbill WHERE ID = '" & ListView1.Items(i).Text & "'"
Dim da As New MySqlDataAdapter(strSQL, CONNECTION)
da.Fill(ds)
End If
Next i
End If
List()
答案 0 :(得分:1)
确保您拥有连接变量
像这样Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim CONNECTION As MySqlConnection = New MySqlConnection
CONNECTION.ConnectionString = "connectionstring"
CONNECTION.Open()
If ListView1.Items.Count > 0 Then
For i = ListView1.Items.Count - 1 To 0 Step -1
If ListView1.Items(i).Checked = True Then
strSQL = "DELETE FROM tbl_hbill WHERE ID = '" & ListView1.Items(i).Text & "'"
Dim da As New MySqlDataAdapter(strSQL, CONNECTION)
da.Fill(ds)
End If
Next i
End If
List()
End Sub