Need help with TableAdapter problem [modified]
-
Solved: I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved. I have a typed DataSet mapping a local SQL Server CE 3.5 .sdf file using DataGridView on a WinForm. I can successfully add and modify data but for some reason I can't delete any. I don't get any errors either. Can you please give me any ideas about what could be wrong? I can't figure this out and I'd appreciate any help. I use simple methods like this:
fill
myTableTableAdapter.Fill(myDataSet.MyTable);add
(after adding new row to grid also to bindingsource)
myTableTableAdapter.Update(myDataSet.MyTable);delete
myDataSet.MyTableRow row = myDataSet.MyTable.FindByID(id);
row.Delete();
myTableTableAdapter.Update(myDataSet.MyTable);The row is gone from gridview. I also check myDataSet.MyTable parameter in myTableTableAdapter.Update(myDataSet.MyTable) using debug visualizer, it's is gone from there too (row status: Deleted). But when I refill data from database, it's back like nothing happend.. I checked DeleteCommand of the myTableTableAdapter, it is defined and correct. I don't copy project database file over the newer build file either. I wrote a simple log to see the rowstatus of the row. Everything seems to work as it should but still the row comes back after a db refill:
Log: row status: Unchanged
Log: calling row.Delete()
Log: row status: Deleted
Log: entering Update() function
Log: row status: Deleted
Log: calling tableAdapter.Update(dataset.Table)
Log: row status: row not found in datasetAny ideas?
modified on Tuesday, May 26, 2009 6:12 AM
-
Solved: I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved. I have a typed DataSet mapping a local SQL Server CE 3.5 .sdf file using DataGridView on a WinForm. I can successfully add and modify data but for some reason I can't delete any. I don't get any errors either. Can you please give me any ideas about what could be wrong? I can't figure this out and I'd appreciate any help. I use simple methods like this:
fill
myTableTableAdapter.Fill(myDataSet.MyTable);add
(after adding new row to grid also to bindingsource)
myTableTableAdapter.Update(myDataSet.MyTable);delete
myDataSet.MyTableRow row = myDataSet.MyTable.FindByID(id);
row.Delete();
myTableTableAdapter.Update(myDataSet.MyTable);The row is gone from gridview. I also check myDataSet.MyTable parameter in myTableTableAdapter.Update(myDataSet.MyTable) using debug visualizer, it's is gone from there too (row status: Deleted). But when I refill data from database, it's back like nothing happend.. I checked DeleteCommand of the myTableTableAdapter, it is defined and correct. I don't copy project database file over the newer build file either. I wrote a simple log to see the rowstatus of the row. Everything seems to work as it should but still the row comes back after a db refill:
Log: row status: Unchanged
Log: calling row.Delete()
Log: row status: Deleted
Log: entering Update() function
Log: row status: Deleted
Log: calling tableAdapter.Update(dataset.Table)
Log: row status: row not found in datasetAny ideas?
modified on Tuesday, May 26, 2009 6:12 AM
Does the delete work in T-SQL?
-
Does the delete work in T-SQL?
-
Solved: I realized I'm a huge dummy and forgot a transaction I wrapped around delete operation. Turns out I forgot to add a trans.Complete() at the end of it. I added it and problem solved. I have a typed DataSet mapping a local SQL Server CE 3.5 .sdf file using DataGridView on a WinForm. I can successfully add and modify data but for some reason I can't delete any. I don't get any errors either. Can you please give me any ideas about what could be wrong? I can't figure this out and I'd appreciate any help. I use simple methods like this:
fill
myTableTableAdapter.Fill(myDataSet.MyTable);add
(after adding new row to grid also to bindingsource)
myTableTableAdapter.Update(myDataSet.MyTable);delete
myDataSet.MyTableRow row = myDataSet.MyTable.FindByID(id);
row.Delete();
myTableTableAdapter.Update(myDataSet.MyTable);The row is gone from gridview. I also check myDataSet.MyTable parameter in myTableTableAdapter.Update(myDataSet.MyTable) using debug visualizer, it's is gone from there too (row status: Deleted). But when I refill data from database, it's back like nothing happend.. I checked DeleteCommand of the myTableTableAdapter, it is defined and correct. I don't copy project database file over the newer build file either. I wrote a simple log to see the rowstatus of the row. Everything seems to work as it should but still the row comes back after a db refill:
Log: row status: Unchanged
Log: calling row.Delete()
Log: row status: Deleted
Log: entering Update() function
Log: row status: Deleted
Log: calling tableAdapter.Update(dataset.Table)
Log: row status: row not found in datasetAny ideas?
modified on Tuesday, May 26, 2009 6:12 AM