【问题标题】:Error while selecting a row from datatable从数据表中选择行时出错
【发布时间】:2014-01-09 10:54:56
【问题描述】:
filteredrows = Server_Tables[i].Select("(TRIM(Tool Stored Place and Sheduled)='" + searchtext + "') OR (TRIM(Workgroup server to connect to dataset in the tool)='" + searchtext + "')");
在执行时,我收到“语法错误:‘存储’运算符后缺少操作数。”
【问题讨论】:
标签:
asp.net
c#-4.0
datatable
datatable.select
【解决方案1】:
这似乎有点奇怪,但如果你真的有两列如上命名,那么你的表达式应该是:
filteredrows = Server_Tables[i].Select("TRIM([Tool Stored Place and Sheduled])='" +
searchtext + "' OR TRIM([Workgroup server to connect to dataset within the tool])='" +
searchtext + "'");
仅当您的 searchtext 变量不包含任何单引号时才这样做。
由于列名中存在空格,因此需要列名周围的方括号