I'm using a function to delete all data from 9 Tables of my database using typed dataset and adaptermanager.UpdateAll
.
The update fails with a DBConcurrencyException
, because one table
throws an RowNotInTableException
.
All I'm doing is Fill all my tables and then delete the rows. There is no other process working on the database. How can the row get detached?
Is there a way to get the primary key of the row that is producing the problem?
My Code (shortened):
--- 6 other fills before
FillDataTable("parameters");
List<AzureDataSet.parametersRow> parRows = (from p in azureDataSet.parameters where p.ID != "undefined" select p).ToList();
foreach (AzureDataSet.parametersRow item in parRows)
item.Delete();
FillDataTable("definitions");
List<AzureDataSet.definitionsRow> defRows = (from sd in azureDataSet.definitions where sd.hashPK != "undefined" select sd).ToList();
foreach (AzureDataSet.definitionsRow item in defRows)
item.Delete();
--- definitions table produces the error, there is only one more table to fill left
AzureDataSetTableAdapters.TableAdapterManager adapterManager = new AzureDataSetTableAdapters.TableAdapterManager();
adapterManager.parametersTableAdapter = new AzureDataSetTableAdapters.parametersTableAdapter();
adapterManager.definitionsTableAdapter = new AzureDataSetTableAdapters.definitionsTableAdapter();
adapterManager.BackupDataSetBeforeUpdate = true;
retryPolicy.ExecuteAction(() =>
{
adapterManager.UpdateAll(azureDataSet);
});
-- EDIT --
I tested the delete operation outside of the adapterManager. So I called every TableAdapter.Update
method separately.
The same table throws the error:
StackTrace:
System.Data.DBConcurrencyException
bei System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
bei System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
bei System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
bei System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
bei System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
bei Apcs.Pcd.NetLib.AzureDataSetTableAdapters.definitionsTableAdapter.Update(AzureDataSet dataSet) in ..\AzureDataSet.Designer.cs:Zeile 21172.
bei ..DeleteAllDatabaseData() in ..:Zeile 2540.
-- EDIT 2: SOLVED --
I could solve my problem, but I have no idea what caused the problem. All I did was opening my DataSet.xsd, open the delete command of the table and save the DataSet again. I changed nothing!