1
I’m trying to save the data of 2 variables in a table, but when I look at the table in the database is recorded the values as 0.
public void inserir(List<Conta>list)
{
List<Conta> lista = new List<Conta>();
lista = list;
try
{
MySqlConnection onclick = new MySqlConnection("server = localhost; port=3306; User Id=root; database = 2.0 banco; password =");
onclick.Open();
MySqlCommand onCmd = new MySqlCommand("INSERT INTO CONTA(nome, cpf) VALUES (nome = @nome, cpf = @cpf)", onclick);
onCmd.Parameters.AddWithValue("@nome",lista[lista.Count-1].GetNome());
onCmd.Parameters.AddWithValue("@cpf", lista[lista.Count - 1].GetCpf());
onCmd.ExecuteNonQuery();
MessageBox.Show("Cadastrado com sucesso: " + lista[lista.Count - 1].GetCpf());
}
catch(Exception erro)
{
MessageBox.Show("Erro ao cadastrar: " + erro);
}
}
}
It worked! Thank you.
– Roberto Mota