bek
asked on
How to update my database table from my grid? (Almost done--just need a little help.)
Hello.
I am trying to cascade my delete from the dataset back to the database. Here's my code. What am I leaving out? The row disappears from the datagrid, but it's still in the database.
(Don't worry about the hardocded '2'. That's just there to simply the problem.
Thanks in advance!
string strSQLDelete = "delete from Inventory where ID= 2";
OleDbCommand cmdDelete = new OleDbCommand (strSQLDelete, dbConn);
resultDA.DeleteCommand = cmdDelete;
DataRow rowDel = ds.Tables ["Inventory"].Rows[1];
ds.Tables["Inventory"].Row s.Remove(r owDel);
resultDA.Update (ds, "Inventory");
I am trying to cascade my delete from the dataset back to the database. Here's my code. What am I leaving out? The row disappears from the datagrid, but it's still in the database.
(Don't worry about the hardocded '2'. That's just there to simply the problem.
Thanks in advance!
string strSQLDelete = "delete from Inventory where ID= 2";
OleDbCommand cmdDelete = new OleDbCommand (strSQLDelete, dbConn);
resultDA.DeleteCommand = cmdDelete;
DataRow rowDel = ds.Tables ["Inventory"].Rows[1];
ds.Tables["Inventory"].Row
resultDA.Update (ds, "Inventory");
ASKER
But how do I get those changes back to my database?
ASKER
I tried adding ds.AcceptChanges() where you said. No errors, but it didn't remove the row from my database.
Any idea what's wrong?
Any idea what's wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I never really got an answer, but figured it out myself. However, if you wish to award the points to jong3, I have no problem with that because he was trying to help me.
We really need the option to delete questions on our own.
We really need the option to delete questions on our own.
In your case:
ds.AcceptChanges();
This function should finalize the deleted rows, and remove it completely from the dataset.