How can I update the values in the database with the values in the DataGridRow when the button is clicked?
To be precise i want to change the text of column from "En cours" to "PRET" when i click the button
public void ajoutercolonne()
{
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
btn.Name = "Validation";
btn.Text = "Prêt";
btn.UseColumnTextForButtonValue = true;
dataGridView2.Columns.Add(btn);
}
Use a ado.net request tu update here is a example:
SqlConnection conn = new SqlConnection("Server=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Trusted_Connection=True;
User Instance=yes");
conn.Open();
string sql2 = "UPDATE student SET moneyspent = " + ?????? + " WHERE id=" + studentIndex + ";";
SqlCommand myCommand2 = new.
SqlCommand(sql2, conn);
See slso here: https://www.c-sharpcorner.com/UploadFile/718fc8/save-delete-search-and-update-record-in-ado-net/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.