当前位置: 代码迷 >> Delphi >> DataRow数组的有关问题
  详细解决方案

DataRow数组的有关问题

热度:5886   发布时间:2013-02-25 00:00:00.0
DataRow数组的问题
prvaite DataRow[ ] rows = new DataRow [4];这个是声明的数组
需要实现功能: 读取表 PreviewFilesQueue 中Times小于3的数据。如果表中数据行为0,直接跳出,否则并以FileType 为条件,筛选出四个 DataRow[ ]数组;
已有条件:我将数据库中取出来的数据全部放到了DataTable里面, string sql = "select * from PreviewFilesQueue where Times<3";
  dt = DbHelperSQL.ExcuteTable(sql);里面有数据,我想知道如何将得到的数据通过判断FileType这个条件放到DataRow数组里面,我要的是往rows[0-3]这4个数组逐个添加条件的方法,FileType的4个条件分别为100,101,102,103.有能够解答的麻烦帮忙看下!急~~~,如果这里不方便的话,可以加我QQ,谢谢!



------解决方案--------------------------------------------------------
DataTable table = DataSet1.Tables["Orders"];
// Presuming the DataTable has a column named Date.
string expression;
expression = "FileType=100";
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]);
}


linq to datatable也是可以的