B
bjako
Hi, I'm going out of my mind with this one.
I have a dataset with a number of tables with parent/child relations
enforced.
I'm trying to replace a row in a parent table, but the issue is that
it sets the rowstate of all the child records in the related tables to
'Deleted'.
This is understandable given the constraint. However the row I am
replacing in the parent table has the same key so once completed the
child rows don't need to be deleted.
The question is how do I do that? I've tried turning off enforce
constraints but that didnt seem to work. Even setting Relations.clear
still deletes the child records on deleting the parent!
My code currently looks like this:
ContractDS.EnforceConstraints = False
Dim drs As DataRow() = ContractDS.Tables(TableName).Select(KeyName &
"='" & KeyValue & "'")
ContractDS.Tables(TableName).Rows.Remove(drs(0))
ContractDS.Tables(TableName).NewRow()
ContractDS.Tables(TableName).ImportRow(dr)
ContractDS.EnforceConstraints = True
I've been going round in circles for hours. The only way I can make it
work is to create the dataset without ANY relations in the first place
which is not ideal.
Any help is most appreciated.
Thanks, Ben.
I have a dataset with a number of tables with parent/child relations
enforced.
I'm trying to replace a row in a parent table, but the issue is that
it sets the rowstate of all the child records in the related tables to
'Deleted'.
This is understandable given the constraint. However the row I am
replacing in the parent table has the same key so once completed the
child rows don't need to be deleted.
The question is how do I do that? I've tried turning off enforce
constraints but that didnt seem to work. Even setting Relations.clear
still deletes the child records on deleting the parent!
My code currently looks like this:
ContractDS.EnforceConstraints = False
Dim drs As DataRow() = ContractDS.Tables(TableName).Select(KeyName &
"='" & KeyValue & "'")
ContractDS.Tables(TableName).Rows.Remove(drs(0))
ContractDS.Tables(TableName).NewRow()
ContractDS.Tables(TableName).ImportRow(dr)
ContractDS.EnforceConstraints = True
I've been going round in circles for hours. The only way I can make it
work is to create the dataset without ANY relations in the first place
which is not ideal.
Any help is most appreciated.
Thanks, Ben.