[英]Error “Missing operand after 'Bannon' operator” - what 'Bannon' operator is?
Working on a C# console app, I have a line:在 C# 控制台应用程序上工作,我有一行:
rowsFound = tempUsers.Select("EmailAddress = '" + userData[2].ToString() + "'");
rowsFound
is a DataRow[]
, tempUsers
is a DataTable
, and userData
is a SqlDataReader
. rowsFound
是DataRow[]
, tempUsers
是DataTable
, userData
是SqlDataReader
。 I had the wrong index for userData
(it was 1) and I got this error:我有错误的
userData
索引(它是 1),我收到了这个错误:
System.Data.SyntaxErrorException was unhandled
Message=Syntax error: Missing operand after 'Bannon' operator.
Source=System.Data
StackTrace:
at System.Data.ExpressionParser.Parse()
at System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
at System.Data.Select..ctor(DataTable table, String filterExpression, String sort, DataViewRowState recordStates)
at System.Data.DataTable.Select(String filterExpression)
When I inserted the correct index (2), the error went away.当我插入正确的索引 (2) 时,错误就消失了。
Any ideas on what a "Bannon operator" is?关于什么是“班农算子”的任何想法?
That guy was probably called O'Bannon
(= userData[1]
), resulting in the following string:那个人可能被称为
O'Bannon
(= userData[1]
),产生以下字符串:
EmailAddress = 'O'Bannon'
The following Stackoverflow question contains a guide on how to properly escape data used in DataTable.Select
:以下 Stackoverflow 问题包含有关如何正确转义
DataTable.Select
中使用的数据的指南:
With respect to single quotes, you just need to duplicate them: '
-> ''
.对于单引号,您只需复制它们:
'
-> ''
。
userData[1].ToString()
was probably something like Bobby' Bannon
userData[1].ToString()
可能类似于Bobby' Bannon
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.