0

我在删除列表视图中的数据时遇到问题,我能够删除列表视图选择记录中的数据,但是选择的数据没有在数据库中删除,我有一个源代码

Private _updateinputalltrans As Boolean

Private Sub btndelete_Click(sender As System.Object, e As System.EventArgs) Handles btndelete.Click
        With Me.listviewpos.SelectedItem
            .Remove()
        End With
        MessageBox.Show("Are you sure delete this record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, New EventHandler(AddressOf DeleteData))
    End Sub

Private Sub DeleteData(ByVal sender As Object, ByVal e As EventArgs)
        Dim conn As New Connection(Connectiondb)
        If Me.updateinputalltrans = False Then
            If Me.listviewpos.Items.Count > 0 Then
                For Each del As ListViewItem In listviewpos.Items
                    conn.delete_dtpospart(del.Text)
                Next
            End If
        End If
    End Sub

delete_dtpospart 使用存储过程声明哪个数据库连接

4

1 回答 1

0

使用此代码将帮助您解决问题

Dim Button = MessageBox.Show _
        ("Are you sure you want to delete this Data?", _
        "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
          If Button = Windows.Forms.DialogResult.Yes Then
        DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
        da.Update(ds, "walkindata")
        If Not ListView1.SelectedItems.Count = 0 Then
        ListView1.Items.Remove(ListView1.SelectedItems.Item(0))
           MsgBox("customer removed in the list.", MsgBoxStyle.Critical)
        Else
        MsgBox("No Customer Selected.", MsgBoxStyle.Critical)
        End If
        Else
        MsgBox("delete is cancel", MsgBoxStyle.Information)
        End If
于 2013-10-18T03:52:32.750 回答