Access Return value of Stored Procedure in SubSonic.

 

To access return value of stored procedure in subsonic you need to add return parameter in stored procedure. You can add return parameters to SP using AddReturnParameter method of stored prodecedure’s command object E.g.SpObj.command.AddReturnParameter();

Folowing is the chunk of code for the same.

StoredProcedure objusptest = SPs.UspTest();

objusptest.Command.AddReturnParameter();

objusptest.Execute();

string strResult=objusptest.Command.Parameters.Find(delegate (QueryParameter objQryPera)

{

        return objQryPera.Mode==ParameterDirection.ReturnValue;

}).ParameterValue.ToString()

In above code I have used SP UspTest that returns a value, and then I have added return parameter using objusptest.Command.AddReturnParameter();.

After executing SP using objusptest.Execute(); it adds return perameter in perameters list.

I have used Find method to find parameter of return type and then access ParameterValue property to access value of return parameter of SP.

3 Responses to Access Return value of Stored Procedure in SubSonic.

  1. Christian van Leeuwen

    Nice, exactly what I was looking for. tnx!

  2. Pingback:   Get Return value of Stored Procedure with SubSonic by codehutch.com

  3. i like……….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s