当我将参数放入我的OLEDB代码时,它成功编译,但它没有完成任务。例如,删除数据代码:
Try
If dbconn.State = ConnectionState.Closed Then
dbconn.Open()
End
Dim dbCommand As OleDbCommand = New OleDbCommand
dbCommand.CommandText = "DELETE FROM UsersTB WHERE First_Name =?"
dbCommand.Connection = dbconn
dbCommand.Parameters.AddWithValue("@row", 0)
Dim rows = dgvusers.SelectedRows
For Each row In rows
dbCommand.Parameters("@row").Value = row.Cells("First_Name").Value
dbCommand.Connection = dbconn
dbCommand.ExecuteNonQuery()
Next
MsgBox("Deleted")
Catch ex As Exception
ex.ToString()
End Try
当我编译时,这个代码写在按钮上,然后单击按钮它不会删除我尝试将其放在try catch上的数据,并将msgbox用于指示命令是否成功,并指示其&#34 ;删除"但它没有用。