解决方案 »

  1.   


    string sql="select * from table where time>'datetime.now.addhours(-2).tostring(yy-mm-ddd.....)'"
      

  2.   

    就是小时是2的整数倍的整点,去执行SQL语句?
    弄个timer,设置1秒执行一次,在里面判断时间,然后执行你的SQL语句就行了
      

  3.   

    从工具箱里拖个timer控件,放窗体里,设置下属性就行了
    不要告诉我访问数据库也不会
      

  4.   

    DateTime.Now.Hour % 2==0,这个吗?
      

  5.   


       TickStart = Environment.TickCount                           '不计点数的开始时间
    .....
    .....
    .....
      If ((Environment.TickCount - TickStart) / 1000.0) < 60*60*2   Then Exit Sub '2H内不计点数
      

  6.   


                Test_Start_Time = Now
                Dim Time_Data1 As Double = New XDate(Test_Start_Time)
    '......
    '......
                Dim Time_Data2 As Double = New XDate(Test_Start_Time.AddHours(2))
                Dim Time_Data3 As Double = New XDate(DateAdd("H", 2, Test_Start_Time))
      

  7.   

    类似这样://创建一个时间范围的字典
     System.Collections.Generic.IDictionary<int, DateTime[]> tmp =
                    new System.Collections.Generic.Dictionary<int, DateTime[]>();            tmp.Add(0, new[]{new DateTime(),new DateTime()});
                tmp.Add(1, new[] { new DateTime(), new DateTime() });
                tmp.Add(2, new[] { new DateTime(), new DateTime() });
                tmp.Add(3, new[] { new DateTime(), new DateTime() });
                tmp.Add(4, new[] { new DateTime(), new DateTime() });
                tmp.Add(5, new[] { new DateTime(), new DateTime() });            //取模 得到字典的key
                int index = Convert.ToInt32(DateTime.Now.Hour%2);            var range = tmp[index];