-1
I’m trying to update a spreadsheet data by textbox. I tried the code below and it did not generate any exception, but did not update the spreadsheet.
private void button2_Click(object sender, EventArgs e)
{
try
{
OleDbCommand command = new OleDbCommand();
command.CommandText = "update [Designa$] set Nome = '" + textBox1.Text + "' where Cod = '"+textBox2.Text+"'";
command.Parameters.Add(new OleDbParameter("@Nome",textBox1.Text));
command.Parameters.Add(new OleDbParameter("@Cod", textBox2.Text));
MessageBox.Show("Dados Atualizados....");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Take out the quotes from Cod and make sure
– Natan Fernandes