Best way to get the identity for new records?

B

Brooke

I am helping develop a SQL Server 2005 application with a C# front-end.
Originally I was using untyped datasets and stored procedures and it worked
fine. Now I have been told to used typed datasets and table adapters. How
do I get the identity for new rerecords? Is it a good idea to use typed
datasets on a database with about 25 tables?

The issue is that I have multiple datagrids that are dependant on each other
and are linked with foreign keys. When I save the records I start with the
highest level form and work my way down on the inserts. The identity is not
generated until the records is written to the db, but I need the identity
for the following child tables.

Thanks
 
E

Earl

I use typed datasets on a database with over 200 tables. It is irrelevant,
because you probably aren't going to create one massive dataset, you are
going to create one dataset for each form. So your datasets will have
typically a handful of tables. If you set your autonumber seed to -1 and
increment to -1, then you can discern your new records by their negative
values. If you use stored procedures, look at the table visualizer once you
have submitted your insert; you should see the newly generated PK out of the
parent tables.
 

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

Top