how To Update The DataGridview Data In DataBase In Winforms Using C#..?
Here Is My Code..With this In Datagridview Only The First Modified Record Only Updating..Remaining Records are not updating. But I need All The Modified Records Should Be Update pls help me.
private void btnUpdate(object sender, EventArgs e)
{
using (OleDbConnection connect = new OleDbConnection(connectionString))
{
using (OleDbCommand command = new OleDbCommand())
{
command.Connection = connect;
command.CommandText = "update customer set Name1=@name,Address=@address where Name1=@name";
command.Parameters.Add(new OleDbParameter("name", OleDbType.VarChar));
command.Parameters.Add(new OleDbParameter("address", OleDbType.VarChar));
connect.Open();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
command.Parameters["name"].Value = row.Cells[0].Value;
command.Parameters["address"].Value = row.Cells[1].Value;
command.ExecuteNonQuery();
}
}
}
}
}