如何在传递给 DataTable Select() 的字符串中包含撇号? [英] How do I include an apostrophe in the string passed to DataTable Select()?

查看:34
本文介绍了如何在传递给 DataTable Select() 的字符串中包含撇号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

撇号 符号在字符串中时,dt.Select(string) 给出错误 missing operand.

The dt.Select(string) gives error missing operand when apostrophe symbol is in the string.

解决这个错误的方法是什么?或者如何处理这个错误?

what is the way to solve this error? or How to handle this error?

推荐答案

String value = "Rubens' Home"; // value you want to sanitize and search
dt.Select(String.Format(
    "Location = '{0}'", value.Replace("'", "''")));

这篇关于如何在传递给 DataTable Select() 的字符串中包含撇号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆