每隔5分钟自动检索数据库中的数据,,,, Windows Apps [英] Auto Retrieval of Data from database in every 5 minute ,,,, Windows Apps

查看:65
本文介绍了每隔5分钟自动检索数据库中的数据,,,, Windows Apps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基于Windows的项目中有一个DatagridView,其中数据需要在每5分钟后从数据库填充一次,或者只要在数据库表中填充新数据

解决方案

  public 表格
{
timer1.Interval =( 1000 )*( 300 ); // 计时器每300秒打一次
timer1.Enabled = ; // 启用计时器
timer1.Start();
}
private void timer1_Tick( object sender,EventArgs e)
{
function();这里调用函数
}


嗨..用户Ajax Timer做同样的事情..你可以使用UpdatePanel来避免页面刷新。

Ex:

Html part ..

 <   asp:  script   manager     runat   =  server    id   =  ScriptManager1    xmlns:asp  < span class =code-keyword> = #unknown    /  >  
< asp:timer id = Timer1 runat = server interval = 50000 ontick = Timer1_Tick xmlns:asp = #unknown >
< / asp:timer >
< asp:updatepanel id = UpdatePanel1 runat = server xmlns:asp = #unknown >
< 触发器 >
< asp:asyncpostbacktrigger controlid = Timer1 eventname = 勾选 / >
< /触发器 >
< contenttemplate >

/ /将您的gridview置于此处以避免页面刷新定期间隔为5分钟

< / contenttemplate >
< / asp:updatepanel >



Interval =50000等于5分钟..



代码落后..

 受保护  void  Timer1_Tick( object  sender,EventArgs e)
{
// 编写加载和绑定数据的代码
}


i hv a DatagridView in Windows Based project, in which data need to be populated from datbase after every 5 minute or as soon as new data is populated in Database tables

解决方案

public Form
{
    timer1.Interval = (1000) * (300);             // Timer will tick every 300 seconds
    timer1.Enabled = true;                       // Enable the timer
    timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
     function(); call function here
}


Hi.. User Ajax Timer do the same.. You can use UpdatePanel to avoid page refresh.
Ex:
Html part..

<asp:scriptmanager runat="server" id="ScriptManager1" xmlns:asp="#unknown" />
        <asp:timer id="Timer1" runat="server" interval="50000" ontick="Timer1_Tick" xmlns:asp="#unknown">
        </asp:timer>
        <asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
            <triggers>
                <asp:asyncpostbacktrigger controlid="Timer1" eventname="Tick" />
            </triggers>
            <contenttemplate>
                
              // place your gridview here to avoid page refresh for regular interval of 5 minutes

            </contenttemplate>
        </asp:updatepanel>


Interval="50000" is equals to 5 minutes..

Code behind..

protected void Timer1_Tick(object sender, EventArgs e)
    {
        //write code to load and bind data
    }


这篇关于每隔5分钟自动检索数据库中的数据,,,, Windows Apps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆