Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

c# convert DateTime to Boolean

Status
Not open for further replies.

dann11

Full Member level 3
Joined
Oct 22, 2015
Messages
166
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,742
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:

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
                      }
}
 

What is Convert.ToBoolean(date) expected to mean? Seems useless.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top