I have a problem where I can't find the bug. The Code is:
int b = cusIdChange.Count - 1;
for (int j = 0; j < cusIdChange.Count; j++)
{
col_1Store[j] = Convert.ToDouble(col_1Store[j]) * Convert.ToDouble(multcol_1_Stor.Text);
col_2Store[j] = Convert.ToDouble(col_2Store[j]) * Convert.ToDouble(multcol_2_Stor.Text);
col_1StoreAsString.Add(Convert.ToString(col_1Store[j]));
col_2StoreAsString.Add(Convert.ToString(col_2Store[j]));
if(col_1StoreAsString[j].Contains(","))
{
convertToStringCol1 = col1_StoreAsString[j].Replace(",",".");
}
else
{
convertToStringCol1 = col1_StoreAsString[j];
}
//same if-else Statement here for Col2
DataTable datTableMult = new DataTable();
sqlCmd = new SqlCommand("UPDATE [" + form1.tableNameVal.Text + "] SET ["+form1.getCol_1Name()+"]= convert(varchar(10)," + convertToStringCol1 + ") WHERE " + form1.cusIdBox.Text + cusIdChange[b] +
" AND (" + form1.prodIdBox.Text + prodIdChange[b] + ")", connection);
//same SQL Statement here for Col2
sqlDatAdapter = new SqlDataAdapter(sqlCmd.CommandText, connection);
sqlDatAdapter.Fill(datTableMult);
form1.setDataGrid3 = datTableMult;
b--;
}
It doesn't want to write the values in my database. Absolutely nothing happens. Both columns have the data type float
, so I convert them to double
in C#.
I have another piece of code thats nearly identical to this one. The difference there is just that I overwrite every single value in the column with a certain entered value and not by a multiplied value like it is in this case. When I use the above code for integers or something else it works fine. I don't know what's wrong with this code. Has to be something with the conversion. When I debug the code, everything looks fine, even the SQL Update
Statement
Aucun commentaire:
Enregistrer un commentaire