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