loading parent row after child row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, when you load a child row when the parent row doesn't exist in a
relational dataset an execption is thrown.
Is there an event to capture this occurence before the exeption is thrown?

Thanks
Bart
 
You might try disabling dataset (DataSet.EnforceConstraints = false)
constraints before loading and re-enable them after load
(DataSet.EnforceConstraints = true).
After the exception is thrown just loop through rows and check their
RowError property.
BTW, why would you want to load such rows in the first place?
 
Hi Miha,

I have a table with a lot of related tables.
When I start the application I'm loading all the data in the correct order,
but the user can call old data also (or via some process), in this case some
related records exist and others not. For the moment I reload all the related
records for all the other related tables. It would be easier if I could load
that specific record and intercept the related records the dataset is
missing, so I could load only those missing records.

Thanks


Miha Markic said:
You might try disabling dataset (DataSet.EnforceConstraints = false)
constraints before loading and re-enable them after load
(DataSet.EnforceConstraints = true).
After the exception is thrown just loop through rows and check their
RowError property.
BTW, why would you want to load such rows in the first place?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Bart said:
Hi, when you load a child row when the parent row doesn't exist in a
relational dataset an execption is thrown.
Is there an event to capture this occurence before the exeption is thrown?

Thanks
Bart
 
Hi,

I agree with Miha, that we can use the EnforceConstraints property to
achieve this. It seems to be the only solution to this scenario, althought
there might be a performance hit if there are a lot of rows in the dataset.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

With the EnforceContraints you can only avoid the exeptions while loading
the records. You have to check for every related record if it already exist
or not.
Supose you could intercept the exeption, load the missing record and just
continue, ignoring the error.

Thanks
Bart
 
Hi Bart,

As this is an uncommon way to use the DataSet, it seems we have to go
through all the rows in the DataSet to get the invalid record which might
lead to a performance hit.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Bart,

As Kevin already mentioned do you have in my opinion to go in advance
through the child datatable. Find the not existing Parents and by instance
create those parents as a kind of dummy or whatever.

Although I would not do that, it is a major (not only computing error) when
those errors exist.

By instance detailorders withouth orders. You are loosing sales than.

Just my thought,

Cor
 
Back
Top