Groups | Blog | Home
all groups > asp.net > december 2005 >

asp.net : How to get @@Identity value using ADO.NET and ASP.NET


Dsquare
12/25/2005 8:59:09 PM
CREATE PROCEDURE sp_InsertMaterial

@MatEngName nvarchar(100),@MatJapName nvarchar(500),@Comments
nvarchar(500),@ImagePath nvarchar(100),@ImageStatus
nvarchar(50),@AddedDate datetime

AS

INSERT INTO
MaterialMaster(MaterialEngName,MaterialJapName,Comments,ImagePath,ImageStatus,AddedDate)

VALUES(@MatEngName,@MatJapName,@Comments,@ImagePath,@ImageStatus,@AddedDate)

SELECT @@IDENTITY as 'Identity'

This is my stored procedure to insert records in a particular table,
using Ado.net i want to retrieve this Identity number....

Can any body help..
Christopher Reed
12/26/2005 12:59:57 AM
Use an output parameter from your stored procedure and capture it as a
parameter in your code.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

[quoted text, click to view]

Karl Seguin
12/26/2005 10:47:07 AM
Agree with the answer given, but thought I'd mention that you should be
using SCOPE_IDENTITY() instead of @@IDENTITY...you can learn more as to why
here:
http://weblogs.asp.net/rosherove/archive/2003/11/13/37217.aspx

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



[quoted text, click to view]

Dsquare
12/28/2005 2:40:04 AM
Thank you very much....
AddThis Social Bookmark Button