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.
Nice, exactly what I was looking for. tnx!
Pingback: Get Return value of Stored Procedure with SubSonic by codehutch.com
i like……….