G
Guest
Dear Ng,
I have a 1(master table) : n(first child table) : m(second child table)
relationship in my sql server and strongly typed dataset. Now I locate the
corresponding row in the master table.
DataAccessControl.DocumentTemplateRow rowTemplate =
tblTemplate.FindBydocumentTemplateId(templateId);
Then i request all child rows:
DataRow[] rowsToDelete =
rowTemplate.GetChildRows("DocumentTemplateDocumentField");
Then I want to delete all child rows in the child tables:
foreach (DataAccessControl.DocumentFieldRow row in rowsToDelete)
{
tblFields.RemoveDocumentFieldRow(row);
}
dac.updateDataAccessLayer();
The delete rules of both relations (from the master to the first child and
from the first to the second child) is set to cascade (in the database and in
the dataset). But if I execute the code, just the rows in the second child
table are deleted. What do I do wrong? If I use additionally the row.delete()
command
foreach (DataAccessControl.DocumentFieldRow row in rowsToDelete)
{
row.Delete();
if (row.RowState == DataRowState.Deleted)
tblFields.RemoveDocumentFieldRow(row);
}
dac.updateDataAccessLayer();
I'll get a DBConcurrencyException! What is wrong? What I want to achieve is
that the master record is kept and all child records are deleted.
Thanks in advance and best regards,
Patrick Braunschweig
I have a 1(master table) : n(first child table) : m(second child table)
relationship in my sql server and strongly typed dataset. Now I locate the
corresponding row in the master table.
DataAccessControl.DocumentTemplateRow rowTemplate =
tblTemplate.FindBydocumentTemplateId(templateId);
Then i request all child rows:
DataRow[] rowsToDelete =
rowTemplate.GetChildRows("DocumentTemplateDocumentField");
Then I want to delete all child rows in the child tables:
foreach (DataAccessControl.DocumentFieldRow row in rowsToDelete)
{
tblFields.RemoveDocumentFieldRow(row);
}
dac.updateDataAccessLayer();
The delete rules of both relations (from the master to the first child and
from the first to the second child) is set to cascade (in the database and in
the dataset). But if I execute the code, just the rows in the second child
table are deleted. What do I do wrong? If I use additionally the row.delete()
command
foreach (DataAccessControl.DocumentFieldRow row in rowsToDelete)
{
row.Delete();
if (row.RowState == DataRowState.Deleted)
tblFields.RemoveDocumentFieldRow(row);
}
dac.updateDataAccessLayer();
I'll get a DBConcurrencyException! What is wrong? What I want to achieve is
that the master record is kept and all child records are deleted.
Thanks in advance and best regards,
Patrick Braunschweig