dann11
Full Member level 3
Hi! I am trying to use time difference and date as my condition to update my counter value. but I certainly get an error of "Invalid cast from 'DateTime' to 'Boolean'." Please help what is the proper conversion.
I have my as below:
I have my as below:
Code:
public void counterUpdate()
{
MySqlConnection conn = new MySqlConnection();
conn = new MySqlConnection(cs);
DateTime t1 = DateTime.Now;
DateTime t2 = resettingTime.valueOfResetTime();
TimeSpan diff = t1 - t2;
if((Convert.ToUInt64(diff.Hours) > 0) && (Convert.ToBoolean(date)))
{
//UpdateValue
{
string stmmbc = "UPDATE `database` SET `Actual` = '"+Counter.getActual().ToString()+"' Where `Date`='"+date.ToString(format)+"'";
MySqlCommand cmd = new MySqlCommand(stmmbc, conn);
cmd.Connection.Open();
try
{
cmd.ExecuteNonQuery();
}
catch(MySqlException ex)
{
MessageBox.Show(ex.ToString());
}
}
}
else
{
//do nothing
}
}