I'm trying to run a code every time, where it takes the value sent by the Arduino COM port, prints it in a textbox, and then generates an insert in the mysql database.
It just read what was sent by the COM port and does not execute the insert. Help me.
private void timer1_Tick_1(object sender, EventArgs e)
{
serialPort1.Open();
string entrada = serialPort1.ReadLine();
serialPort1.Close();
txtIDTag.Text = entrada;
if (txtIDTag.Text == "Gol")
{
string sql = "insert into tcc (Carro,Placa,Fabricante,Ano,Cor,Status,Data) value ('" + txtIDTag.Text + "','SCD - 4365','VW','2010','PRETO','NOVO', NOW())";
comando.CommandText = sql;
conexao.Open();
comando.ExecuteNonQuery();
conexao.Close();
MessageBox.Show("Dados cadastrados com sucesso.");
txtIDTag.Text = "";
}}
I tried to get the IF that he executed.