Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 我无法删除datagridview中的文件_Vb.net_Datagridview_Error Handling_Delete File - Fatal编程技术网

Vb.net 我无法删除datagridview中的文件

Vb.net 我无法删除datagridview中的文件,vb.net,datagridview,error-handling,delete-file,Vb.net,Datagridview,Error Handling,Delete File,我正在使用以下代码: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim result = MessageBox.Show("Delete This Record?", "Confirm Action", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

我正在使用以下代码:

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
    Dim result = MessageBox.Show("Delete This Record?", "Confirm Action", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If result = DialogResult.Yes Then
        Dim sqldelete As String
        sqldelete = "DELETE * FROM [product info] WHERE Barcode='" & DataGridView1.CurrentRow.Cells(6).Value.ToString & "'"
        Dim adapter As New OleDbDataAdapter(sqldelete, strcon)
        Dim dt As New DataTable("[product info]")
        adapter.Fill(dt)
        DataGridView1.DataSource = dt

        RefreshDGV()
    End If
当我在datagridview中选择要删除的项目时,会显示一个错误,说明:

没有为一个或多个必需参数提供值


我不熟悉此错误,因为我的“删除”按钮代码以前是有效的。

为什么要使用“代码隐藏”来处理此错误?如果您正确设置了DataGridView,您只需将所有SQL放入控件中,让它为您处理删除操作……我们建议您使用代码进行删除,而不是DataGridView附带的控件。您可以通过msgboxDataGridView1.CurrentRow.Cells6.Value.ToString进行测试。。有什么价值吗?谢谢@matzone那行有个错误。它应该是qldelete=DELETE*FROM[product info],其中[Barcode]='&DataGridView1.CurrentRow.Cells6.Value.ToString&'我在单词Barcode中添加了大括号您使用的是什么数据库?从…中删除*。。。不正常,是否应从…中删除。。。?另外,请发布DataGridView1.CurrentRow.Cells6.Value.ToString的返回。这是重要的信息。