lothos12345
Well-known member
I am trying to execute a delete command put it is throwing an unexpected exception at the nonquery line. I have no ideal why I have posted the code I am using below. Any help is greatly appreciated.
Dim delStr As String
MessageBox.Show("Are you sure you wish to delete this record?", "Deletion", MessageBoxButtons.OKCancel)
DataSet11.Clear()
objConnection = New OleDb.OleDbConnection()
objConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & "\\Wcmazda\database folder\DailyFloorOpps\AllStoresDB\DailyFloorOpps.mdb"
delStr = "DELETE * FROM FloorOpps WHERE mainid = " & fldrecord.Text & ""
objConnection.Open()
objAdapter.DeleteCommand = New OleDb.OleDbCommand()
objAdapter.DeleteCommand.Connection = objConnection
objAdapter.DeleteCommand.CommandText = delStr
objAdapter.DeleteCommand.ExecuteNonQuery() <---- Error
objAdapter.Fill(DataSet11, "FloorOpps")
objConnection.Close()
Dim delStr As String
MessageBox.Show("Are you sure you wish to delete this record?", "Deletion", MessageBoxButtons.OKCancel)
DataSet11.Clear()
objConnection = New OleDb.OleDbConnection()
objConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & "\\Wcmazda\database folder\DailyFloorOpps\AllStoresDB\DailyFloorOpps.mdb"
delStr = "DELETE * FROM FloorOpps WHERE mainid = " & fldrecord.Text & ""
objConnection.Open()
objAdapter.DeleteCommand = New OleDb.OleDbCommand()
objAdapter.DeleteCommand.Connection = objConnection
objAdapter.DeleteCommand.CommandText = delStr
objAdapter.DeleteCommand.ExecuteNonQuery() <---- Error
objAdapter.Fill(DataSet11, "FloorOpps")
objConnection.Close()