DataTable 使用Select方法查詢並排序,以及【拼接轉義符的問題】


關於DataTable 里面用 /轉義符拼接的問題

//這種寫法表面上是正確,實現上在運行時調用Select方法實行查詢會報錯 
string str = resetstrWhere + "\"" + "," + "\"" + dataQuery.DefaultOrderByClause; table = table.Select(str).CopyToDataTable();

 

 

//這種寫法表面上是正確,實現上在運行時調用Select方法實行查詢會報錯
string
str = string.Format("{0}\",\"{1}", resetstrWhere, dataQuery.DefaultOrderByClause); table = table.Select(str).CopyToDataTable();

 

 

 

//這種方法是正確的。
DataTable table =new DataTable(); table = table.Select(string.Format("{0}", resetstrWhere), string.Format("{0}", Tool.sortName + strtype)).CopyToDataTable();

 

 

 

DataTable 使用Select方法

Select();

Select("id>='3' and name='3--hello'");//支持and

Select("id>='3' or id='1'");//支持or

Select("name like '%hello%'");//支持like   

 Select("id>5","id desc");

Select("id>5", "id desc",DataViewRowState.Added);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM