I been trying to get a simple output from a stored procedure
ALTER PROCEDURE [dbo].[sp_getrandomnumber]
@randoms int output
AS
begin
set @randoms =1234
Your problem is that your SPROC output is an int.
See the following quote from Scott Gu's article.
"LINQ to SQL maps "out" parameters in SPROCs as reference parameters (ref keyword), and for value types declares the parameter as nullable."
So you need to make sure you're declaring randoms
as a nullable int.
Change your sp call to
public ActionResult Index()
{
// @randoms int output from SPROC.
int? randoms = null;
// qry would contain a select if you had one in the SPROC.
var qry = db.sp_getrandomnumber(ref randoms);
// randoms is 12345
return View();
}
Find another example here.