Israel

Israel

  • 701
  • 1.3k
  • 217.3k

Time must be egual to data system

Sep 29 2019 4:50 PM
Hi,
 
I have on my form a Timer1, Label1 and Label2.
 
Then on my OnLoad Event I put:
  1. Timer1.Start();  
  2. conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename=C:\\myFolder\\App_Datas\\DB.mdf;Integrated Security = True;Integrated Security = True");  
  3. conn.Open();  
  4. string commandString = "select top 1 * from operation where S='" + "S" + "' order by nord desc";  
  5. SqlCommand comm = new SqlCommand(commandString, conn);  
  6. SqlDataReader read = comm.ExecuteReader();  
  7. if (read.HasRows)  
  8. {  
  9. while (read.Read())  
  10. {  
  11. Label1.Text = read["time"].ToString();  
  12. }  
  13. }  
  14. else  
  15. {  
  16. }  
  17. read.Close();  
  18. conn.Close();  
  19. if Label1.Text = DateTime.Now.ToString()  
  20. Label2.txt = "Yes";  
On my timer_Click I put this:
  1. Label1.Text = DateTime.Now.ToString("HH:mm");  
What I need?
 
When the time its equal to the date system its should display on Label2 the word "yes". Otherwise its cant activate the second Label2.

Answers (3)