954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to code timer that will change the datas in a database

I need a timer that will change the text of a combobox which is binded to a database.
My Application which is based on hospital management wherein a doctor has to visit rooms within 6 hours. If 6 hours elapse the combo should show "need......" and if not something "......" and the changes should be also written in the database as there are many rooms. there should also be a button that resets the timer. please help me. Thank you so much

jnyekha
Newbie Poster
4 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 
I need a timer that will change the text of a combobox which is binded to a database. My Application which is based on hospital management wherein a doctor has to visit rooms within 6 hours. If 6 hours elapse the combo should show "need......" and if not something "......" and the changes should be also written in the database as there are many rooms. there should also be a button that resets the timer. please help me. Thank you so much

There is a timer that you can add to your application, just drag it from the toolbox to anywhere on your application.

private void timer1_Tick(object sender, EventArgs e)
{
//Code to be executed
}


Double click it and add the code to be executed when it ticks. you can set how long between each tick by setting the interval property of the timer, this is an int and holds the time in ms between each tick so for 6 hours you would need 21,600,000 as the value.

//set timer to tick every 10seconds
timer1.Interval = 10000


there are also methods for starting and stopping the timer.

Hope this helps

midimatt
Light Poster
49 posts since Mar 2008
Reputation Points: 34
Solved Threads: 4
 

Well you could always use the DateTime call in C#, and just do a check for when it equals 6 hours from it, here's a link on that

http://msdn.microsoft.com/en-us/library/system.datetime.aspx

But if this in not for real and more a test run or just project, I would probably with what midimatt says, that would work well (plus it seems like he has alittle better programing experience then me)

Ange1ofD4rkness
Junior Poster
123 posts since May 2010
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: