Answer the question
In order to leave comments, you need to log in
How to update a specific row of a db table in a dataGridView?
I displayed my query in the datagridview element, where my table with the MySQL database is displayed.
I'm trying to make it so that when I click on any row in the datagridview, it will automatically enter the value in the column with an Update query.
here is my code:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
string CommandText;
Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);
for (int i = 0; i < selectedRowCount; i++)
{
CommandText = "UPDATE `auto`.`transportation` SET `active` = 'X' WHERE(`idtransportation` = '" + dataGridView1.Rows[i].ToString() + "');";
My_Execute_Non_Query(CommandText);
button1_Click(sender, e);
}
}
Answer the question
In order to leave comments, you need to log in
Is id equal to table row?
You need a specific table cell.
dataGridView1.Rows[i].Cells[0].Value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question