c# - SQLCommand.Parameters.Add - How to give decimal value size? -
how specify this:
decimal(18,2)
in this:
sqlcomm.parameters.add("@myvalue", sqldbtype.decimal, 0, "myvalue");
currently have defined precision = 2
design side properties. i'm curious how accomplish code.
there's not overload of add
lets set decimal precision inline, either need create sqlparameter object , add collection:
sqlparameter param = new sqlparameter("@myvalue", sqldbtype.decimal); param.sourcecolumn = "myvalue"; param.precision = 18; param.scale = 2; sqlcomm.parameters.add(param);
or "find" parameter after adding it:
sqlcomm.parameters.add("@myvalue", sqldbtype.decimal, 0, "myvalue"); sqlparameter param = sqlcomm.parameters["@myvalue"]; param.precision = 18; param.scale = 2;
Comments
Post a Comment