1
I cannot use the UPDATE command more than once.
(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)
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 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//within it, in the case of the ID in the database tb. And 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 does, but in msm ID, it is fixed in the first ID I did the update.
Missing database schema and an example of the sql update you are using
– Sveen
Sorry, I couldn’t make it. Now it’s gone, thank you!
– Gabriel Augusto
Put your code as text the editor has tools for this. Use images unless necessary
– Barbetta
Where is the assignment of
att
?– Leandro Angelo
Ready put the code, is that I am without internet in the computer..
– Gabriel Augusto
I declared the int variable att; between functions within the form...
– Gabriel Augusto