The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

How to get value from output paramtere from SP

Last post 10-18-2007, 4:47 AM by Mike.Griffin. 1 replies.
Sort Posts: Previous Next
  •  10-18-2007, 2:02 AM 5903

    How to get value from output paramtere from SP

    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   
    
     
  •  10-18-2007, 4:47 AM 5904 in reply to 5903

    Re: How to get value from output paramtere from SP

    I found this example real quick using search for "output parameter" Wink

     

    Code:
    esUtility u = new esUtility();
    u.Schema = "MYGENERATION";
    
    esParameters esParms = new esParameters();
    esParms.Add("ID", esParameterDirection.Output, DbType.Decimal, 4);
    u.ExecuteNonQuery(esQueryType.StoredProcedure, "PROC_GETNEXTID", esParms);
    
    esParameter param = esParms["ID"];
    Console.WriteLine(param.Value.ToString()); 

     

    This is using the esUtility but it works the same no matter what.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML