以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 在应使用条件的上下文(在 'exp' 附近)中指定了非布尔类型的表达式? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=134257) |
-- 作者:gudao123456 -- 发布时间:2019/5/1 21:18:00 -- 在应使用条件的上下文(在 'exp' 附近)中指定了非布尔类型的表达式? 执行以下代码时,提示错误:在应使用条件的上下文(在 \'exp\' 附近)中指定了非布尔类型的表达式。 Dim exp As String = CExp("[csr] = \'{0}\' And [tjzt] ={1} and [cszt]= \'{2}\'", "zzhh" ,1,"待审") Dim cmd As new SQLCommand cmd.C cmd.CommandText= "sel ect username,gzxx,hjszd,lqgxjzy,lqgxcc,tpcl,lqzyym ,cszt From dxxsxxb where exp" With wb.AddTable("","Table1") .CreateFromDataTable(cmd.ExecuteReader) end with 而在SQL窗直接执行:se lect username,gzxx,hjszd,lqgxjzy,lqgxcc,tpcl,lqzyym,cszt From dxxsxxb where [csr]=\'zzhh\' and [tjzt]=1 and [cszt]=\'待审\' 时却能正常显示结果 ,是什么原因?谢谢! 补充:[tjzt] 为逻辑型字段,其他为字符型字段 [此贴子已经被作者于2019/5/1 21:39:29编辑过]
|
-- 作者:有点甜 -- 发布时间:2019/5/4 10:42:00 --
cmd.CommandText= "select username,gzxx,hjszd,lqgxjzy,lqgxcc,tpcl,lqzyym ,cszt From dxxsxxb where exp"
改成
cmd.CommandText= "select username,gzxx,hjszd,lqgxjzy,lqgxcc,tpcl,lqzyym ,cszt From dxxsxxb where " & exp
|
-- 作者:gudao123456 -- 发布时间:2019/5/4 17:31:00 -- 当时好像是加“”&“”了的,但屡试都不行,后来不知不觉却加上了,就行了,就没有去考究了。谢谢! [此贴子已经被作者于2019/5/4 17:31:47编辑过]
|