How to solve issue of single quote in filer value using DataTable.Select()

后端 未结 3 991
慢半拍i
慢半拍i 2021-01-22 05:18

Assuming I want productCode variable below to be assigned the product code of a product named Cookie\'s

NOTE the \"\'\" in the the Prod

3条回答
  •  天命终不由人
    2021-01-22 05:34

    Double up any single quotes like this

    ...dt.Select("[ProductName] = '" + filterValue.Replace("'", "''") + "'")[0]["ProductCode"]
    

提交回复
热议问题