简体   繁体   中英

How to store an int value from stored procedure and pass it to controller

I have table license as below

table Licence
 [ LID(pk) int,
   ProID(FK) int,
   SK string,
   QTY int,
   LIS int,
   LIU int
]

and I have "chklin" as stored procedure to retrieve LIU.

procedure [dbo].[chklin]
(@LID int)
as
begin
select LIU from license where LID=@LID
end

Now in my License controller, I have below action

public ActionResult Chk(int L)
    {
        SLMEntitiesDB dbContext = new SLMEntitiesDB();
        dbContext.chklin(L) // this should check the LIU value, how to pass it 
    to below IF statement

if (A == 0)
    {
        ViewBag.Message = "No more license available";
    }
    else
    {
        return RedirectToAction("create", "users");
    }

You can assign the value of the result of the result of the procedure to a variable and check the value of the Variable in your If statement. Like this

var A = dbContext.chklin(L)
if(A == 0){
 ViewBag.Message = "No more license available";
} else{
 return RedirectToAction("create", "users");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM