1
I cannot use the UPDATE command more than once.
For example, when I do the update on id 43, sure. But when I try to finish 44, it does not finish, but 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 does, but in msm ID, it is fixed in the first ID I did the update.
Imagery
https://drive.google.com/file/d/1xyqp6rA4Rk3AvneFaUlqk6AVvjQjbtSi/view?usp=drivesdk https://drive.google.com/file/d/190WFQ0cxGWYJw2aO66xBNvOsNftY7CAk/view?usp=drivesdk https://drive.google.com/file/d/1-XS3NeZm7cU0_4Pi7r2fY4dCNNAjCKtf/view?usp=drivesdk
you have asked this question before the problem is in the value assignment of the variable att...
– Leandro Angelo
And remove your previous question.
– Leandro Angelo
You tested my answer?
– Leandro Angelo