/// <summary>
        
/// 执行DataTable中的查询返回新的DataTable
        
/// </summary>
        
/// <param name="dt">源数据DataTable</param>
        
/// <param name="condition">查询条件</param>
        
/// <returns></returns>

      private 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;//返回的查询结果
        }

 

       另外,datatable.Select()多个条件选择语句和SQL语句类似,如:DataTable.Select("ID=" + id +" and name='" +name + "'")

posted on 2010-10-13 15:25  飞翔-方向 积累 沉淀  阅读(747)  评论(0)    收藏  举报