DataTable.Select()

调用

Select.SelectRows()

调用

Select.GetRows()

返回

DataRow[]

Select对象访问级别为internal

 

 

测试代码:

            DataTable dt = new DataTable();
            dt.Columns.Add("Source");

            DataRow dr = dt.NewRow();
            dr["Source"] = "hao123mphhn'b'b'bb'bb' 'b";
            dt.Rows.Add(dr);

            // 转义正确
            string filterExp = string.Format("Source = '{0}'", "hao123mphhn'b'b'bb'bb' 'b".Replace("'", "''"));
            //// 转义不正确
            //string filterExp = string.Format("Source = '{0}'", "hao123mphhn'b'b'bb'bb' 'b".Replace("'", "\'"));
            DataRow[] rowFounds = dt.Select(filterExp);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-10-29
  • 2021-09-05
  • 2022-12-23
  • 2021-07-24
猜你喜欢
  • 2021-12-24
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-12-01
  • 2021-11-02
相关资源
相似解决方案