When I was working on a system with a teacher some time ago, when I wrote a stored procedure under MSSQL, I encountered the problem of output-type return values and return-type return values;
After some attempts, I understand it. I 'd like to share it with you;
Return is a custom keyword returned by MSSQL. Its usage is relatively simple.
Eg
Select * from student where Dep = @ Dep
Return @ rowcount
Return @ rowcount returns the number of affected rows,
In sqlhelper, you can use cmd. Parameters ["returnvalue"]. Value to obtain the return value.
However, if the output-type return value also uses the returnvalue to return the value, an exception occurs,
Eg
Create procedure sp_higheducation_articlerole_getcredbycondition
@ Categoryid nvarchar (16 ),
@ Authorplace nvarchar (16 ),
@ Grade int output
As
Select @ grade = getcred from articlerole where categoryid = @ categoryid and authorplace = @ authorplace
Go
In sqlhelper
If (CMD. Parameters [Grade]. value. tostring () = "")
{
Return 0;
}
Else
{
Return Int. parse (CMD. Parameters [Grade]. value. tostring ());
}
Of course, this is an output-type return value. For Multiple Output-type return values, it should be filled in DS and DT.