我有这个方法来更新我的数据库。我想从表中选择一些单元格并更新它,例如我想更改单元格(ID [1],Name [Peter],LastName [Holg])------> [ID [2 ],名称[Rob],LastName [Clein])但我不知道如何在datagrids中选择它们。
表:ID_Customer / Name / Lastname
public void Customer()
{
DataTable update = new DataTable("Customer");
update.Columns.Add("ID_Customer");
update.Columns.Add("Name");
update.Columns.Add("LastName");
Cust_Map customer= new Cust_Map();
Customer customer1= new Customer ();
customer1.ID_Customer = Convert.ToInt32(dataGridView1.Rows[dataGridView1.RowCount - 2].Cells[0].Value);
customer1.Name = Convert.ToString(dataGridView1.Rows[dataGridView1.RowCount - 2].Cells[1].Value);
customer1.LastName = Convert.ToString(dataGridView1.Rows[dataGridView1.RowCount - 2].Cells[2].Value);
update.Rows.Add(customer1.ID_Customer, customer1.Name, customer1.LastName);
customer.Update(customer1.ID_Customer, customer1.Name, customer1.LastName);
}