By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,564 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,564 IT Pros & Developers. It's quick & easy.

How do I determine if an expected DataTable ChildRow doesn't exist and add it if doesn't?

P: n/a
I have a DataSet containing a Parent/Child relationship that has been
populated by Sql Server. I have an expectation that certain child records
should exist for each parent based upon column data. If, for some reason,
these child records don't exist I would like to add them.

Here is a scenario, Billing installment detail are children of a billing
header record, with the number of installs called out by the header. The
children are being bound to controls on a WinForm and should, at the least,
exist in an initialized state, although the database cannot be relied upon
to contain them until they are created.

What is the best way to determine non-existent detail rows in a business
object class and add them if they are not found?
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

For a data row you want to check the child records existence, use the:

DataRow[] DataRow.GetChildRows (...)

method using appropriate attributes to specify the relation you want to use.

Then, in the child table you can add rows and set the parent row using

DataRow.SetParentRow (...) method.

Then it's enough to update the database using the dataset with the
modifications.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply

"Top Gun" <nf*@nospam.com> wrote in message
news:e0**************@TK2MSFTNGP12.phx.gbl...
I have a DataSet containing a Parent/Child relationship that has been
populated by Sql Server. I have an expectation that certain child records
should exist for each parent based upon column data. If, for some reason,
these child records don't exist I would like to add them.

Here is a scenario, Billing installment detail are children of a billing
header record, with the number of installs called out by the header. The
children are being bound to controls on a WinForm and should, at the least, exist in an initialized state, although the database cannot be relied upon
to contain them until they are created.

What is the best way to determine non-existent detail rows in a business
object class and add them if they are not found?


Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.