- /// <summary>
- /// 执行DataTable中的查询返回新的DataTable
- /// </summary>
- /// <param name="dt">源数据DataTable</param>
- /// <param name="condition">查询条件</param>
- /// <returns></returns>
- public static DataTable GetNewDataTable(DataTable dt, string condition)
- {
- DataTable newdt = new DataTable();
- newdt = dt.Clone();
- DataRow[] dr = dt.Select(condition);
- for (int i = 0; i < dr.Length; i++)
- {
- newdt.ImportRow((DataRow)dr[i]);
- }
- return newdt;//返回的查询结果
- }
- public static DataSet GetNewDataSet(DataSet inputds, string condition)
- {
- DataTable newdt = new DataTable();
- newdt = inputds.Tables[0].Clone();
- DataRow[] dr = inputds.Tables[0].Select(condition);
- for (int i = 0; i < dr.Length; i++)
- {
- newdt.ImportRow((DataRow)dr[i]);
- }
- DataSet outputds = new DataSet();
- outputds.Tables.Add(newdt);
- return outputds;
- }