Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-07
2
Medium Priority
?
338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

705 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