Problem with access and c #

0

I am running the following code, in the fifth line I get an error:

  

"The input string does not have the correct format"

costo = Convert.ToDouble(textBox8.Text);
string fecha = DateTime.Today.ToString("dd/MM/yyyy");
OleDbCommand actualizacion = new OleDbCommand("update servicios set estado_servicio = 'Finalizado', costo = @costo, fecha_entrega = '" + fecha + "' where clave = @parametro and estado_servicio = 'Reparacion'", conexion);
actualizacion.Parameters.AddWithValue("@costo", costo);
actualizacion.Parameters.AddWithValue("@parametro", Convert.ToInt32(textBox4.Text));
actualizacion.ExecuteNonQuery();

My key field is an autonumer field *

    
asked by jose marquez 14.11.2016 в 21:45
source

2 answers

2

You say that this is the line that gives you an error:

actualizacion.Parameters.AddWithValue("@parametro", Convert.ToInt32(textBox4.Text));

That means that textBox4.Text does not contain a value that can be converted to an integer.

Note apart, since you are using parameters for @costo and @parametro (I congratulate you), it would be good if you would do the same with fecha .

    
answered by 14.11.2016 / 22:07
source
0

Hello you should validate the data before persisting against the database, for example if it is empty and that the TextBox control allows you to enter only integers or only letters, you could use this custom control.

TextBox-ComboBox

    
answered by 15.11.2016 в 00:24