您的位置:首页 > 其它

DataTable 使用Select方法查询并排序,以及【拼接转义符的问题】

2015-06-09 10:13 651 查看
关于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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: