I can not use the UPDATE command more than once.
For example, when I perform the update at id 43, that's fine. But when I try to finish 44, it does not finish, but the 43 that gets the update ..
Code:
Int att,index;
Private void DataGrid_CellClick(object sender, DataGridViewCellEventsArgs e) {
if(e.RowIndex >= 0)
{
Index = e.RowIndex;
att = Convert.ToInt32(DataGrid.Rows[Index].Cells[0].Value);
}
}
//quando clico numa célula, Att recebe o número que está //dentro dela, no caso correspondente ao ID na database tb. E index recebe o índice da linha.
private void Btnfnz_Click(objetc sender, EventArgs e)
{
If(index >=0)
{
var linha = DataGrid1.Rows[index];
cn.Connection = Conexão.conectar();
cn.CommandText = "UPDATE Atendimento SET HorarioOut = ' " + Txthr.Text + " ' WHERE ID=@att";
cn.Parameters.AddWithValue("@att",att);
cn.ExecuteNonQuery();
cn.Connection = Conexão.desconectar();
}
else
{
MessageBox.Show("Lista vazia!");
}
Refreshatt(); //Carrega o datagrid com dados do banco dados, onde horarioOut estiver em branco.
}
Everything works fine, but when I try to do a new update, it even does, however in the msm ID, it is fixed in the first ID I made the update.
Images