DataTable.LoadDataRow -Documentation error!!!

  • Thread starter Thread starter John Viele
  • Start date Start date
J

John Viele

The documentation of DataTable.LoadDataRow() has a major omission. To
quote:

"Finds and updates a specific row. If no matching row is found, a new row is
created using the given values."

What this does NOT tell you is that it ignores any rows which have the
INSERTED or UPDATED flags set. It only correctly updates the data table if
you have already called AcceptChanges() on your data table.

Well, this little omission costed me HOURS of work. I designed a routine
to update an entire dataset (including a number of data tables) in one big
swoop so that I can call Update() inside a transaction to do all the inserts
and updates at one time. Unfortunately, that routine fails miserably due to
duplicated keys. This occurs when you call LoadDataRow() more than once
with the same primary key expecting an UPDATE to an existing row AS THE
DOCUMENTATION STATES!

At a minimum the documentation needs to be corrected. On the other hand,
most every other function that can affect rows in the data table gives you
the ability to specify flags indicating which rows to ignore. Why on earth
wouldn't that be available on this function?
 
Yep, one more example showing that it would be better to use business
objects and not to rely on DataTables and DataSets.
IMHO.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top