473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2006
Hi Lam,
depends on what kind of control you are trying to update. You can use a
System.Window.Forms.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.Interval = 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.labelCurrentValue.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*********@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
Hi Lam,
depends on what kind of control you are trying to update. You can use a
System.Window.Forms.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.Interval = 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.labelCurrentValue.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
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...
11
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...
19
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
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...
6
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...
19
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...
15
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...
5
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...
2
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,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.