Strongly Typed Datasets, New Rows, and Concurrency

Strongly Typed Datasets, New Rows, and Concurrency

Post by David Englan » Tue, 12 Mar 2002 00:48:10



I'm playing with ADO.NET, a Jet database, and Strongly Typed Datasets and
have the following questions:

1) At what point should I populate the primary key (GUID) for a new row?  I
would like to have the Dataset object I've created handle this whenever a
new row is created to avoid having the client code be responsible for adding
the value.  I've tried overriding the DataRow.New method, but this seems to
be called under several circumstances (retrieving existing rows, updating
the dataset) and leads to concurrency errors when dealing with existing
rows.

2) Dealing with (avoiding) concurrency errors when updating a row that has
null values.  I'm using the default SQL generated by the DataAdapter to
update rows and check for concurrency issues.  This works fine as long as
each strongly typed field has a legal value.  However, if a field is empty
(null), a concurrency error is generated ... I'm guessing this is due to a
StronglyTyped exception.  However, I'd rather not have the user be forced to
enter data for non-required fields.  I've worked around this by removing the
concurrency checking from the DataAdapter's Update statement and creating
code that rereads the dataset and does a manual compare of the modified rows
using DataRowVersion, but this seems a time intensive way to do this.  Am I
missing something?

Thanks in advance for any advice!

David England