My Setup - ASP.net and SQL2005 using SP
How to retrive output value from SP. (Line 5- VMIDpk is not returning any value)
I modified default SP generated from MgGen (line -10,14,15)
I want to generate customised Primary key in SP and return that value.
Code:
1 MProfile mProfile = new MProfile();
2 mProfile.AddNew();
3 mProfile.CProfileCreatedBy = this.profilecreatedby.Text;
4 mProfile.Save();
5 string MemberID = mProfile.VMIDpk;
6
7
8 PROCEDURE [dbo].[proc_MProfileInsert]
9 (
10 @vMIDpk varchar(10)= NULL Output,
11 @cProfileCreatedBy char(1) = NULL)
12 AS
13 BEGIN
14 SELECT @vMIDpk = max(Cast(vMIDpk as int))+1 FROM [MProfile]
15 IF( @vMIDpk IS NULL ) SET @vMIDpk = 1
16
17 INSERT
18 INTO [MProfile]
19 (
20 [vMIDpk],
21 [cProfileCreatedBy]
22 )
23 VALUES
24 (
25 @vMIDpk,
26 @cProfileCreatedBy
27 )
28 END
29