以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  这个语句在数据库中执行是正确的,确定时出错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=143039)

--  作者:xxfoxtable
--  发布时间:2019/11/12 12:34:00
--  这个语句在数据库中执行是正确的,确定时出错
cmd.CommandText="S ELECT  "cregno" = a.cregno,"cguestname" = (Case left(a.cregno,1) when \'S\' then \'非住客\' else (s elect cguestname from ft_his_xs_reg_1 where cregno = a.cregno) end),"cguesttype" = (Case left(a.cregno,1) when \'S\' then \'非住客\' when \'T\' then \'团体\' else (s elect cguesttype from ft_his_xs_reg_1 where cregno = a.cregno) end), &  _
   "cpaytype" = (Case isnull(cyjflag,\'N\') when \'Y\' then \'押金\' else (case when a.npayamt >= 0 then \'结帐收款\' else \'结帐退款\' end ) end),"paywayno" = a.cpaywayno, "paywayname" = IsNull(c.cpaywayname,a.cpaywayno), "face" = a.nface, "ngetamt" = a.ngetamt,  "change" = a.nchange,  & _  
         "npayamt" = a.npayamt, "voucherno" = a.cvoucherno, "memo" = a.cmemo, "operID" = a.coperID, "operdate" = a.dt_oper, "croomno" = (Case left(a.cregno,1) when \'T\' then \'团体\' when \'S\' then \'非住客\' else a.croomno end)  , "croomno1" = (Case left(a.cregno,1) when \'T\' then \'团体\' when \'S\' then \'非住客\' else a.croomno end)  , &  _
   "ccomputer" = a.ccomputer  FROM ft_his_xs_pay_2 a,  ft_pu_payway c   WHERE  ( a.cpaywayno *= c.cpaywayno ) And   ( a.dt_oper  >= 开始时间 ) And  ( a.dt_oper  <  结束时间 ) And  ( a.dt_oper  >= \'" & dtp1.value &"\') And   ( a.dt_oper  < \'" & dtp2.value &"\')"

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2019/11/12 13:40:00
--  
把列名的双引号全部去掉,"cregno" 改为cregno
--  作者:xxfoxtable
--  发布时间:2019/11/12 14:02:00
--  
去掉双引号后出现如下错误

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2019/11/12 14:25:00
--  
cmd.CommandText="S ELECT   a.cregno,(Case left(a.cregno,1) when \'S\' then \'非住客\' else (s elect cguestname from ft_his_xs_reg_1 where cregno = a.cregno) end)  as cguestname,(Case left(a.cregno,1) when \'S\' then \'非住客\' when \'T\' then \'团体\' else (s elect cguesttype from ft_his_xs_reg_1 where cregno = a.cregno) end) as cguesttype, ....