Repply below

-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED]]On Behalf Of Matthew
Sent: Sunday, 7 July 2002 2:09 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] ADO.NET: Parent-child relationship and
auto-increment columns


Hi,

Here's a tricky one. I have a DataSet with two tables, with a parent-child
relationship defined between them. I want to add a new parent, and then
add a new child for that parent. However, the rows are linked using a
foreign key relationship on the parent's auto-increment ID, which
won't be generated until I reconnect to the data source and update changes
(with a data adapter). Is there any way to link these two rows together
before I perform the update?

Generate an initial key - see below.


Secondly, what's the purpose of the DataColumn.AutoIncrement property? If
you enable this feature, and ADO.NET generates an auto-increment value on
its own while disconnected, isn't there a good chance that this value will
conflict with one generated by another disconnected client?

The Microsoft recommendation is to autogenerate a -1 number with a -1
increment . (search on Autoincrement identity) .
When you pass the data do NOT pass the indentity let the DB generate a new
identiy during inserts.  The insert shoucl do a select at the end and
re-populate the record for any changes and the Constraints will update all
foreiign keys. Unlike DB's you can easily change autoincrement identity
collumsn in datasets.


Ben


Matthew

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to