ExecuteSqlCommand with output parameter

前端 未结 6 1019
名媛妹妹
名媛妹妹 2020-12-06 04:43

I\'m using Entity Framework in an ASP.NET MVC3 application and I\'m trying to use the following code:

var token = \"\";
this.Database.ExecuteSqlCommand(\"exe         


        
6条回答
  •  无人及你
    2020-12-06 05:00

    var outParam = new SqlParameter();
    outParam.ParameterName = "OutPutParametname";
    outParam.SqlDbType = SqlDbType.Bit;//DataType Of OutPut Parameter
    outParam.Direction = ParameterDirection.Output;
    db.Database.ExecuteSqlCommand("EXEC ProcedureName @Param1,@Param2 OUTPUT", new SqlParameter("Param1", value), outParam);
    object outParamValue = Convert.ToBoolean(outParam.Value);
    

提交回复
热议问题