I am developing an application and all of my code reads and inserts into an mdb database file. However when I try to update, the code executes without issue, but when I check the database, the updates are not there. Here is my update code:
Any help would be greatly appreciated.
Code:
else if(isNewEntry == false)
{
string query = "UPDATE hours SET hoursWorked = @p3 WHERE contactID = @p1 AND fiscalYearID = @p2";
cmd.CommandText = query;
foreach (DataGridViewRow row in dgvTime.Rows)
{
id = Convert.ToInt16(row.Cells["contactID"].Value);
hours = Convert.ToInt16(row.Cells["hoursWorked"].Value);
year = yr;// Convert.ToInt16(cbFiscalYear.SelectedIndex.ToString());
cmd.Parameters.AddWithValue("@p1", id.ToString());
cmd.Parameters.AddWithValue("@p2", year.ToString());
cmd.Parameters.AddWithValue("@p3", hours.ToString());
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.Connection.Close();
pbEnteringData.PerformStep();
}
pbEnteringData.Value = 0;