A textbox
returns the value 0.7
through the property .text
, executing a Convert.ToDouble(txt.text)
This converts the string into a number of type Double
with this value 0.7
(So far everything is correct), But when I put this value into the database that expects to obtain values of type it Double
loads an integer with the value of 7
itself if I load the value by hand in the database the value takes it correctly.
I will simplify part of the code that does not need to be shown to make it less cumbersome
Function that calls the routine with which I load the database:
if (conn.State == ConnectionState.Closed)
{
conn.ConnectionString = path;
conn.Open();
}
string query = "CALL `Routine_AgregarNuevoValor_Materiales`( '" + _Espesor + "'");
MySqlCommand cmd = new MySqlCommand(query);
cmd.CommandText = query;
cmd.Connection = conn;
cmd.ExecuteNonQuery();
Routine in the database:
BEGIN
INSERT INTO `stock de materias primas` (`Espesor`) VALUES (Espesor);
END
What is the problem and how can I fix it?
Hello, I think the detail is in the way you are concatenating this part.
Since by having ( '" + _Thickness + "'"); what it will do is return it a
string
for the ' ' that you put before it, I think that is why it returns an integer.It could be solved just by putting it as follows.
Thus, the data that you have already converted into a Double should respect the format.
Cheers