I have a .NET 2010 application hitting SQL2000 db. The code is pretty simple. When I insert a record, the record is inserted, but the identifier is not returned. The id column is an int, and this is an identification. This is where proc is stored ...
ALTER PROCEDURE Insert_Vendor
@CorpID as varchar(255),
@TaxpayerID as varchar(255)
AS
Insert into dbo.Vendor
(
vdr_CorpID,
vdr_TaxpayerID
)
values
(
@CorpID,
@TaxpayerID
)
IF @@error <> 0
BEGIN
RETURN -1
END
ELSE
RETURN @@Identity
GO
And on the receiving side ...
int myID = (int)(db.ExecuteScalar(dbCommand));
source
share