Hello,
I'm new to ADO.Net and need help on using ADO.Net to delete records from an Oracle database. Based on a book I read, I need to set my adapter's DeleteCommand and the deletes on a dataset would be saved onto the database.
Below is a sample code of how I'm trying to do it. I can see that the row is deleted from the dataset but the delete is not propagated to the database when I call the adapter's Update. What am I missing? I have also defined my InsertCommand and UpdateCommand and the inserts and updates are applied on the dataset and the database properly.
Thank you.
I'm new to ADO.Net and need help on using ADO.Net to delete records from an Oracle database. Based on a book I read, I need to set my adapter's DeleteCommand and the deletes on a dataset would be saved onto the database.
Below is a sample code of how I'm trying to do it. I can see that the row is deleted from the dataset but the delete is not propagated to the database when I call the adapter's Update. What am I missing? I have also defined my InsertCommand and UpdateCommand and the inserts and updates are applied on the dataset and the database properly.
Thank you.
Code:
Dim ds as Dataset = new Dataset("ds")
Dim objAdapter As Oracle.DataAccess.Lite.OracleDataAdapter = New OracleDataAdapter
cmdSel = CreateCommand()
cmdSel.CommandText = "SELECT ..."
objAdapter.SelectCommand = cmdSel
objAdapter.Fill(ds, "tab")
' -- delete any item from dataset
ds.Tables("tab").Rows.RemoveAt(4)
cmdDel = CreateCommand()
cmdDel.CommandText = "DELETE ..."
objAdapter.DeleteCommand = cmdDel
objAdapter.Update(ds, "tab")