when i run my update code it says successfully updated but when i try to see my database , nothing has been updated.
will someone please help me what to do. im just a beginner i don't know how will i fix this
will someone please help me what to do. im just a beginner i don't know how will i fix this
C#:
[FONT=Consolas]
try
{
this.time2.Text = DateTime.Now.ToString("hh:mm tt");
this.label8.Text = System.DateTime.Now.ToShortDateString();
ad.UpdateCommand = new OleDbCommand("update Attendance_Records set " + " [Time_Out] = @Time_Out " + " where Emp_id = @Emp_id and Date = @Date", cn);
ad.UpdateCommand.Parameters.AddWithValue("@Emp_id", label4.Text.ToString());
ad.UpdateCommand.Parameters.AddWithValue("@Time_Out", time2.Text.ToString());
ad.UpdateCommand.Parameters.AddWithValue("@Date", dateTimePicker1.Value.ToShortDateString());
if (DateTime.Now.ToString("hh tt") == "12 PM")
{
cn.Open();
ad.UpdateCommand.ExecuteNonQuery();
MessageBox.Show("Time OUT Successfull");
cn.Close();
}
else
{
MessageBox.Show("Sorry TimeOUT Time IS AT 12:00 PM");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
[/FONT]