c# - Send float parameter through SqlDatasource.InsertParameter -


hi trying insert float value database through sqldatasource.insertparameter after sqldatasource.insert() function executed see integer part of inserted in database. have debugged , checked before execution of sqldatasource.insert() value stored in sqldatasource float. below code:

function data layer:

     public static sqldatasource datasourceinsert(string sp, string[,] param) {     float f;     ds = new sqldatasource();     if (cns.state != connectionstate.open)         cns.open();     ds.connectionstring = configurationmanager.connectionstrings["cns"].connectionstring;     ds.insertcommandtype = sqldatasourcecommandtype.storedprocedure;     ds.insertcommand = sp;      (int = 0; < param.getlength(1); i++)     {         ds.insertparameters.add(param[0, i], param[1, i]);         ds.insertparameters[param[0, i]].defaultvalue = param[1, i];         if(float.tryparse(param[1, i],out f))             ds.insertparameters[param[0, i]].type = system.typecode.double;     }     ds.insert();     return ds; } 

parameter p

protected void dv_iteminsert(object sender, detailsviewinserteventargs e) {     string procname = "spaddandinsertproduct";     string[,] p = new string[2, 5];     p[0, 0] = "productname";     p[1, 0] = ((textbox)((detailsview)sender).rows[0].cells[1].controls[0]).text;     p[0, 1] = "description";     p[1, 1] = ((textbox)((detailsview)sender).rows[1].cells[1].controls[0]).text;     p[0, 2] = "ispublished";     p[1, 2] = ((textbox)((detailsview)sender).rows[2].cells[1].controls[0]).text;     p[0, 3] = "quantity";     p[1, 3] = ((textbox)((detailsview)sender).rows[3].cells[1].controls[0]).text;     p[0, 4] = "price";     p[1, 4] = ((textbox)((detailsview)sender).rows[4].cells[1].controls[0]).text;     ds = sqlinteractor.datasourceinsert(procname, p);      prodadmin_insertdv.datasource = ds;     prodadmin_insertdv.databind();     gv_databind(); } 

there 2 things need check: a) culture setting working with, , string representations of float values match up? error. b) less need operate double, either handle conversion double on db side better, or because data values require it.


Comments