Using SqlDBType.Decimal in Prepared Statement C#

后端 未结 4 1954
难免孤独
难免孤独 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:28

    The following would set a Decimal with Precision 18 and Scale 8 (Decimal (18,8))

    SqlCommand insertCommand= new SqlCommand(supInsert, connection);
    insertCommand.Parameters.Add("@ordQty", SqlDbType.Decimal,18);
    
    insertCommand.Parameters["@ordQty"].Precision = 18;
    insertCommand.Parameters["@ordQty"].Scale = 8;
    
    insertCommand.Prepare();
    u = insertCommand.ExecuteNonQuery();
    

提交回复
热议问题