0

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

enter image description here

public void ajoutercolonne()
{
    DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
    btn.Name = "Validation";
    btn.Text = "Prêt";
    btn.UseColumnTextForButtonValue = true;
    dataGridView2.Columns.Add(btn);
}
1

1 Answer 1

0

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/

Sign up to request clarification or add additional context in comments.

1 Comment

Wide open to sql injection, do not do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.