我现在datatable中有我3分钟接收到的N条数据,我如何像数据库中那样,根据主键,寻找到在三分钟内接收到这个数据范围内的最大时间值和最小时间值。

解决方案 »

  1.   

    写线程,3分钟跑一次,执行一次sql查询
      

  2.   

    关键的是DATATABLE中也可以用sql语句吗?那要怎么写。
      

  3.   

    table.Compute("max("时间字段")", "").ToString();
    table.Compute("min("时间字段")", "").ToString();
      

  4.   

    DataTable..::.Select 方法 
    看看MSND吧
    private void GetRowsByFilter()
    {
        DataTable table = DataSet1.Tables["Orders"];
        // Presuming the DataTable has a column named Date.
        string expression;
        expression = "Date > #1/1/00#";
        DataRow[] foundRows;    // Use the Select method to find all rows matching the filter.
        foundRows = table.Select(expression);    // Print column 0 of each returned row.
        for(int i = 0; i < foundRows.Length; i ++)
        {
            Console.WriteLine(foundRows[i][0]);
        }
    }
      

  5.   

    datatable.defaultview.filter(表达式)
    也可以
      

  6.   

    试试DataTable.Select("time between .. and .. ");
      

  7.   

    读入dataset的时候加字段time为显示当前时间。
    每3分钟执行命令,根据time字段查看这段时间内的接收数据的最早和最晚收到的值