DataTable筛选器

//datatable筛选器,函数包装模板:传入源table,目标table,db名,多表查询table,列条件数组,where筛选列,selsect筛选列

public DataTable Filter(DataTable room, DataTable room1, string dbname, DataTable build, string[] split,string c_Name, string column)

{

db.TableName = dbname;

room1 = room.Clone();

string buildFilter = "";

for (int i = 0; i < split.Length; i++)

{

build = db.GetDataTable("select c_Code from " + dbname + " where "+c_Name+" = '" + split[i] + "'");

DataRow[] GetRows = room.Select(column + " = " + build.Rows[0][0].ToString());

foreach (DataRow row in GetRows)

{

room1.Rows.Add(row.ItemArray);

}

}

return room1;

}

 

你可能感兴趣的:(Datatable)