Using SqlDBType.Decimal in Prepared Statement C#

后端 未结 4 1990
难免孤独
难免孤独 2021-01-11 10:56

am using a Prepared Statement in C#.

 SqlCommand inscommand = new SqlCommand(supInsert, connection);
 inscommand.Parameters.Add(\"@ordQty\", SqlDbType.Decim         


        
4条回答
  •  感动是毒
    2021-01-11 11:17

    You will have to explicitly define precision and scale for this parameter.

    SqlParameter ordQty = cmd.Parameters.Add("@ordQty", SqlDbType.Decimal);
    ordQty.Precision = x; //Replace x with what you expect in Sql Sp
    ordQty.Scale = y; //Replace y with what you expect in Sql Sp
    ordQty.Value = 18; //Set value here
    inscommand.Parameters.Add(ordQty);
    

提交回复
热议问题