为什么我的 datagridview.rowfilter 不起作用。我不断收到语法错误消息
我的应用程序有一个填充的数据表,并通过设置 datasource 属性将其绑定到 ddatagridview。
在运行时我想过滤这个表。当用户单击按钮时,我运行以下代码:
dataManager.VDMSTables.DataTable.DefaultView.RowFilter = column + " LIKE '%" + criteria + "%'";
所有类均已正确填充。在运行时,当我到达这一行时,我收到以下错误消息:
语法错误:“数据”运算符后缺少操作数。我用于构建行过滤器的变量已正确填充。即使当我对字符串进行硬编码时,我仍然会遇到同样的错误。为什么?
My application has a populated datatable and binds it to a ddatagridview by setting the datasource property.
At run time I want to filter this table. When the user clicks a button I run the following code:
dataManager.VDMSTables.DataTable.DefaultView.RowFilter = column + " LIKE '%" + criteria + "%'";
All the classes are populated correctly. At runtime when I reach this line I get the following error message:
Syntax error: Missing operand after 'Data' operator. The variables that I use to build the rowfilter are correctly populated. Even when I hard code a string I still get this same error. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在调试器中查看您正在构造的实际字符串时,它看起来是什么样子? “数据”这个词没有出现在那里,是吗?
如果是这样,那么它告诉您数据是保留字,您需要将其标记为保留字。如:
这将产生:
... 应该为您的 RowFilter 正确解析。
What does the actual string you're constructing look like when you view it in the debugger? The word "Data" doesn't show up in there, does it?
If so, then it's telling you that Data is a reserved word and you need to mark it as such. As in:
That will produce:
... which should parse correctly for your RowFilter.