Additional information: The input string was not in a correct format [duplicate]

1

What's wrong with my code?

conexao.conectarBD();
conectar.Open();
comando.CommandType = CommandType.StoredProcedure;

comando = new SqlCommand("INSERIR_CLIENTE", conectar);
comando.Parameters.AddWithValue("@CODIGO", Convert.ToInt32(txtCodigo.Text));
comando.Parameters.AddWithValue("@NOME", txtNome.Text);
comando.Parameters.AddWithValue("@TELEFONE", txtTelefone.Text);

comando.ExecuteNonQuery();
MessageBox.Show("DEU BOM!");
    
asked by anonymous 20.03.2017 / 20:26

1 answer

0

What's wrong is that txtCodigo.Text has a value that could not be converted to int .

See this answer for more details.

    
20.03.2017 / 21:44