Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » .NET Programming (VB 2010 or earlier) » ASP.NET » How to retrieve identity column value after...


How to retrieve identity column value after...Expand / Collapse
Author
Message
Posted 1/17/2009 11:22:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 1/17/2009 11:05:38 AM
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
Post #26757
Posted 1/19/2009 10:32:51 AM
Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: 7/15/2011 3:57:36 PM
Posts: 371, Visits: 208
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

Post #26774
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 3:52am