Solved

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

Posted on 2003-11-07
2
336 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 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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