这句话是不能执行,还是达不到效果。
goodsType 的内容是什么。建议看看这个:
http://expert.csdn.net/Expert/topic/1384/1384270.xml?temp=.784115

解决方案 »

  1.   

    goodsType是一个字符串啊,我在deplhi中在select 中用 case这样用时是能用的,在VB应该差不多啊。我主要是想问一下select XX=case XX when XX then XX ...end 这句话要怎么写!谢了!
      

  2.   

    select 
    (CASE XX WHEN 条件1 TEHN 答案1
            WHEN 条件2 TEHN 答案2
            WHEN 条件3 TEHN 答案3
            ELSE 无答案 END) AS XX
      

  3.   

    "select id as 库存单编号,goodsname as 存货名称,type as 类型,num as 数量,date as 最后入库日期,introduce as 摘要,(case belong when '1' then '固定资产' when '2' then '低值易耗品' end) AS 种类  from store where type='" & goodsType & "'"
      

  4.   

    主要是错在case语句:
    sqlstr="select id as 库存单编号,goodsname as 存货名称,type as 类型,num as 数量,date as 最后入库日期,introduce as 摘要,(case belong when '1' then '固定资产' when '2' then '低值易耗品' end) as 种类    from store where type='" & goodsType & "'"

    其中Chr(&H22)是双引号 "
    如果使用
    sqlstr="select id as 库存单编号,goodsname as 存货名称,type as 类型,num as 数量,date as 最后入库日期,introduce as 摘要," _
    & "case belong when '1' then '固定资产' when '2' then '低值易耗品' end from store where type='" & goodsType & "'"
    即去掉belong的别名
      

  5.   

    好像上传时有问题,在上面的第二种句法是
    sqlstr = "select id as 库存单编号,goodsname as 存货名称,type as 类型,num as 数量,date as 最后入库日期,introduce as 摘要," _
    & "(case belong when '1' then '固定资产' when '2' then '低值易耗品' end) " & Chr(&H22) & "种类" & Chr(&H22) & " from store where type='" & goodsType & "'"
    其中Chr(&H22)是双引号 "