MVC c# 调用sql的存储过程

var hid = new SqlParameter { ParameterName = "HistoryId", Value = history.Id, Direction = ParameterDirection.Input };
var sid = new SqlParameter { ParameterName = "StoreId", Value = StoreId, Direction = ParameterDirection.Input };
var qrcode = new SqlParameter { ParameterName = "QRCode", Value = strQRCode, Direction = ParameterDirection.Input };
var guidcode = new SqlParameter { ParameterName = "GUIDCode", Value = strGUIDCode, Direction = ParameterDirection.Input };
var result = new SqlParameter { ParameterName = "Result", Value = 0, Direction = ParameterDirection.Output };
db.Database.ExecuteSqlCommand("exec @Result = OptStock @HistoryId,@StoreId,@QRCode,@GUIDCode", hid, sid, qrcode, guidcode, result);


model.Status = (int)result.Value;

存储过程为OptStock,带参数输入,输出

posted @ 2016-08-11 15:09  Paras  阅读(4059)  评论(1编辑  收藏  举报