I can not use the UPDATE command more than once.
( link )
( link )
( link )
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 and) {
if(e.RowIndex >= 0)
{
Index = e.RowIndex;
att = Convert.ToInt32(DataGrid.Rows[Index].Cells[0].Value);
}
}
// when I click on a cell, Att receives the number that is // inside it, in case corresponding to ID in database tb. E index receives the index of the line.
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.