Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


How to retrieve identity column value after inserting data into the table?


How to retrieve identity column value after inserting data into the...

Author
Message
johndevid0987
johndevid0987
Forum God
Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)Forum God (1.1K reputation)

Group: Forum Members
Posts: 3, Visits: 1
I am doing an asp.net using C# to program an application which accept user input and save into database then it requires approval. There is a colum in table that approved_or_not. So this purpose i created another page where admin can login to enter the id number which is generated by DB to approve or reject. So every time user input data and submit the application needs to send the identity colum nuber (PK) as an email to admin.

disney dvds

, los angeles seo
TallOne
TallOne
Forum God
Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)

Group: Forum Members
Posts: 370, Visits: 212
You'll need an output parameter in the add stored procedure.  You add this parameter in c# code same as others but define it as type output.  When executing your command object it will look something like this

lMyLongValue = command.executeScalar;

This will set your variable to the the return value of the stored procedure.

Your stored procedure will include something like this:

DECLARE @ReturnValue AS INTEGER

INSERT INTO xTABLE....

SET @ReturnValue = @@Identity
SELECT @ReturnValue

Post your code and I'll give you hand if needed.

Good Luck

TallOne

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search