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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -