Solved

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

Posted on 2003-11-07
2
332 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
Comment Utility
0
 
LVL 4

Author Comment

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

15 Experts available now in Live!

Get 1:1 Help Now