Solved

ADO.NET method to capture newly inserted row's key.

Posted on 2003-11-07
2
334 Views
Last Modified: 2012-06-27
I have two tables in SQLServer.
I insert a new row into table1, which creates a new ID as an identity default primary key.
I need to get that key value to update a second table as a foreign key relationship to the first table.

I could use a command object to insert the table1.row and another to return the most recently added id-key.

I could use a command object to run a stored procedure that returns as an output parameter the id-key.

I could ask the experts what the proper way to accomplish this is. . .

I prefer to learn the best way to do this using ADO.NET.
0
Comment
Question by:JohnChapin
2 Comments
 
LVL 4

Accepted Solution

by:
NetPointer earned 250 total points
ID: 9703014
0
 
LVL 4

Author Comment

by:JohnChapin
ID: 9748148
I had the answer you gave already,
Really wanted a more ADO.NET -centric answer.
GUess there isn't one!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now