SQLCommand.Parameters.Add - How to give decimal value size?
问题 How would you specify this: Decimal(18,2) In this: SqlComm.Parameters.Add("@myValue", SqlDbType.Decimal, 0, "myValue"); Currently I have defined precision = 2 from the design side properties. I'm just curious as to how to accomplish this from the code. Thanks 回答1: There's not an overload of Add that lets you set the decimal precision inline, so you either need to create a SQlParameter object and add it to the collection: SqlParameter param = new SqlParameter("@myValue", SqlDbType.Decimal);