473,769 Members | 2,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refresh the output

Lam
Hi
I try to write a C# windows program which will read some data from database
and display on the screen. It has to refresh the output every 10 seconds
because
the database keep growing every seconds.
so how can I do the refresh?

Thanks
Nov 17 '05 #1
2 2026
Hi Lam,
depends on what kind of control you are trying to update. You can use a
System.Window.F orms.Timer to cause an event to fire every few seconds which
calls a method, inside the method you can fetch your new values and update
your control i.e.

//event that handles a start button being clicked - you don't need this but
I just put it hear for clarity in the example.

System.Windows, Forms.Timer m_objTimer = null;

public void btnStart(Object sender, EventArgs e)
{
//if it is already running need to stop existing timer
if(m_objTimer != null)
{
m_objTimer.Stop ();
}
else
{
m_objTimer = new System.Windows. Forms.Timer();
}

//set the number of milliseconds between each timer event ie 10sec
m_objTimer.Inte rval = 10000;

//add the handler function that will handle to timer tick event
m_objTimer.Tick += new EventHandler(m_ objTimer_Tick);
}
public void btnStop(Object sender, EventArgs e)
{
//if it is already running need to stop existing timer
if(m_objTimer != null)
{
m_objTimer.Stop ();
}
}
//this function is called every time the timer raises a tick event
private void m_objTimer_Tick (object sender, EventArgs e)
{
//fetch data from database

//update controls with new data
this.labelCurre ntValue.Text = strDatabaseText
}
Hope that helps
Mark.

"Lam" wrote:
Hi
I try to write a C# windows program which will read some data from database
and display on the screen. It has to refresh the output every 10 seconds
because
the database keep growing every seconds.
so how can I do the refresh?

Thanks

Nov 17 '05 #2
Lam
Thanks
I didn't try it yet..but it seems to be working

"Mark R. Dawson" <Ma*********@di scussions.micro soft.com> wrote in message
news:45******** *************** ***********@mic rosoft.com...
Hi Lam,
depends on what kind of control you are trying to update. You can use a
System.Window.F orms.Timer to cause an event to fire every few seconds which calls a method, inside the method you can fetch your new values and update
your control i.e.

//event that handles a start button being clicked - you don't need this but I just put it hear for clarity in the example.

System.Windows, Forms.Timer m_objTimer = null;

public void btnStart(Object sender, EventArgs e)
{
//if it is already running need to stop existing timer
if(m_objTimer != null)
{
m_objTimer.Stop ();
}
else
{
m_objTimer = new System.Windows. Forms.Timer();
}

//set the number of milliseconds between each timer event ie 10sec
m_objTimer.Inte rval = 10000;

//add the handler function that will handle to timer tick event
m_objTimer.Tick += new EventHandler(m_ objTimer_Tick);
}
public void btnStop(Object sender, EventArgs e)
{
//if it is already running need to stop existing timer
if(m_objTimer != null)
{
m_objTimer.Stop ();
}
}
//this function is called every time the timer raises a tick event
private void m_objTimer_Tick (object sender, EventArgs e)
{
//fetch data from database

//update controls with new data
this.labelCurre ntValue.Text = strDatabaseText
}
Hope that helps
Mark.

"Lam" wrote:
Hi
I try to write a C# windows program which will read some data from database and display on the screen. It has to refresh the output every 10 seconds
because
the database keep growing every seconds.
so how can I do the refresh?

Thanks

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
27617
by: kindermaxiz | last post by:
I have a php script with a form that insert data in a mysql db and when I click on submit I would like the page to refresh after the insertion, how can I do that? it's a php script that display data from a mysql db, and the submit button modify the content of the page yet I need to manually refresh to see the result of my insertion. it kinda looks like this: echo "<form method=\"post\" action=$php_self>"; echo...
11
3764
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows 2003 Server or ADO or ODBC issue, I am posting this on all of the three newsgroups. That's the setup: Windows 2003 Server with IIS and ASP.NET actiavted Access 2002 mdb file (and yes, proper rights are set on TMP paths and path,
19
36547
by: Jay | last post by:
I'm trying to refresh browser when some new information is available in DB. is there any way to force to refresh browser? Thanks. -Kev
7
15442
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
6
9172
by: Mark | last post by:
i'm using an html form to submit comments to a database. the form is on the same page where the comments are being displayed. if you hit submit, your comment appears as it should, but then if you hit refresh there is a duplicate post. how might i fix this?
19
2219
by: Justin | last post by:
Harlow... i need some help on these... im actually trying to do a page using php... the function is to receive certain parameters from a 3rd party provider... and i need to redirect my page to another page after certain validation. it's ok when i use the url to do the testing... the validation part works fine... scenario as below: if situation a, echo abc if situation b, echo abc then refresh to another page.
15
4960
by: ABC | last post by:
Hi, I have a problem with Double submission in html forms. I am using PHP as the server side scripting language, i have found a means to capture the second form submission while the first form submission is still in-progress. Basically, i can use sessions to check if the first submission is active and reject subsequent submits. ***I do not want to try any client side solution(such as disabling submit button) as hitting F5 on the...
5
495
by: SimonZ | last post by:
When user insert some data on page and click save button this data is inserted to database. If he clicks refresh button, the data is saved again each time when he clicks this button. I would like to prevent refresh from that page, so I inserted the following lines in code behind on page_load event: Response.Cache.SetCacheability(HttpCacheability.NoCache);
2
2256
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data, and a javascript file to to the clever stuff. when i access the html page, all the data is displayed correcty, but if i add or delete any records, and press the button i have created to refresh the data(without reloading), the data doesn't change....
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.