相关疑难解决方法(0)

DataTable表达式无法解释令牌'!'

我有以下代码:

//myDataTable has the following collumns: UserName, Birthday and email.
string name = "eric!";
string expression = "UserName = " + name;
DataRow[] result = myDataTable.Select(expression);
Run Code Online (Sandbox Code Playgroud)

我想选择所有名称为“ eric!”的行。
“!” 给我以下错误:

无法解释令牌“!”。

如何选择带有此类标记的所有行?
(由于从.sql文件中提取了用户名,因此我确实需要在表达式中加上“!”)

c# datatable expression syntax-error token

4
推荐指数
1
解决办法
7665
查看次数

标签 统计

c# ×1

datatable ×1

expression ×1

syntax-error ×1

token ×1