语法错误:'12'运算符后缺少操作数. [英] Syntax error: Missing operand after '12' operator.
本文介绍了语法错误:'12'运算符后缺少操作数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,我的代码行是
dv.RowFilter ="Date =" + Convert.ToDateTime(reportdate);
Date是我表中一列的名称,其类型为Datetime.
reportdate是字符串类型的变量.
我收到此SyntaxErrorException.
语法错误:"12"运算符后缺少操作数.
请帮助我解决此错误.
谢谢.
hii friends, my line of code is
dv.RowFilter = "Date=" + Convert.ToDateTime(reportdate);
Date is the name of a column in my table and is of type Datetime.
reportdate is a variable of type string.
I am getting this SyntaxErrorException.
Syntax error: Missing operand after ''12'' operator.
plz help me to solve this error.
Thanks.
推荐答案
这是因为缺少"行过滤器中的撇号"
当您通过将DataView的RowFilter
属性设置为字符串来过滤DataView时,请注意撇号,否则会出现异常.您需要做的是将每个撇号加倍,例如这有效:
It is because of missing ''Apostrophe in Row Filter''
When you filter a DataView by setting itsRowFilter
property to a string watch out for apostrophes or you’ll get an exception. What you need to do is double each apostrophe, e.g. this works:
dv.RowFilter = "CompanyName = ''Margie''''s Travel''"
更正您的RowFilter表达式,就可以了.
Correct your RowFilter expression and you will be fine.
这篇关于语法错误:'12'运算符后缺少操作数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文