多谢 latahu,9456;我的代码如下,麻烦看一下,有什么问题。
Try
Dim intNum As Integer = dgrdProd.CurrentRowIndex
Dim strDMval As String = Trim(oDSet.Tables(0).Rows(intNum).Item(0))
Dim strInfo As String = "当前记录(产品代码为:" & strDMval & ")将被删除且不可恢复,是否继续?"
Dim strTitle As String = "确认"
Dim intRetu As Integer = MessageBox.Show(strInfo, strTitle, MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
If intRetu = DialogResult.Yes Then
Dim strDeleSQL As String = "DELETE * FROM ProdInfo where CPDM='" & strDMval & "'"
Dim oConn As OleDbConnection = New OleDbConnection(strConn)
oConn.Open()
Dim oCMD As OleDbCommand = New OleDbCommand(strDeleSQL, oConn)
oCMD.ExecuteNonQuery()
oCMD.Dispose()
Dim oAdapt As OleDbDataAdapter = New OleDbDataAdapter(strSele, oConn)
oDSet.Clear()
oAdapt.Fill(oDSet, "Product")
oConn.Close()
oAdapt.Dispose()
oConn.Dispose()
Else
Exit Sub
End If
Catch err As Exception
MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try