Ben Kloosterman <[EMAIL PROTECTED]> wrote:
>
> 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.

I can see how that might work for inserting rows into a single table, but I
don't understand how it addresses the poster's original quetion, which
involved adding a *new* parent row, and a *related* child row.  Since the DB
will invent its own identity column, how on earth do you indicate that the
newly-added child should be related to the newly added child.

Is the normal technique to do several round trips to the DB?  (I.e. update
the parent, retrieve the new key, update the DataSet to reflect the chosen
key, then update the child table.)  Is that workable?

Also, what does the SELECT statement that retrieves the key that the DB
chose look like in practice?  If the DB has invented a new primary key, how
on earth do I tell it which record I'm looking for?  Don't I need to know
what the new primary key was before I can ask for the record?  Or are you
using the magic @@IDENTITY value?  (And how are you pushing it back to the
DataSet?  Manually?  Or is there a way of automating this with a
DataAdapter?)

--
Ian Griffiths
DevelopMentor

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