Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-07
2
Medium Priority
?
340 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 1000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses

927 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