Returning the value of an identity column during/after INSERT command
Posted
by Adam Kane
on Stack Overflow
See other posts from Stack Overflow
or by Adam Kane
Published on 2010-04-08T03:20:09Z
Indexed on
2010/04/08
3:23 UTC
Read the original article
Hit count: 461
Using VS 2010, with ASP.NET, and .NET 3.0, and C#...
When I use a System.Web.UI.WebControls.SqlDataSource and call its Insert() method to insert a new row, and that table has an identity column, I'd like my method to return the value of that column.
For example, in my SQL 2005 table, I've got:
Customer.Id Customer.FirstName Customer.LastName
Where Customer.Id is an identity colum.
When I call my method InsertNewCustomerRecord( "John", "Smith" ), I'd like to be able to return the Customer.Id that gets automatically generated in the database.
Sorry for such a roughly posed question. Let me know if I can add better detail. Thanks.
© Stack Overflow or respective owner