select id,p_code,product,p_product,p_width,p_width_fb,p_length,p_length_fb,p_muwen,printno,p_account, 
( select count(id) from VIEW_product_code AS b where b.p_id in ('780361','780540','780539','780366') and b.product=a.product and b.p_width=a.p_width and b.p_length=a.p_length and b.p_muwen=a.p_muwen ) AS sumshu 
from VIEW_product_code AS a where p_id in ('780361','780540','780539','780366') 
order by replace(left(product,patindex('%[^a-zA-Z0-9]%',product)-1),'TB',''),case when product = '标准件' then 0 when left(product,2) = 'TB' then 1 else 2 end, p_width desc,p_length desc,p_muwen,id,p_code
看看这SQL错在哪里呢?
怎么在网页程序运行时没有找到记录,而在查询分析器中运行却有记录的?
要怎么修改才能在ASP网页程序中正常查询到数据记录呢?

解决方案 »

  1.   

    select id,p_code,product,p_product,p_width,p_width_fb,p_length,p_length_fb,p_muwen,printno,p_account, 
    ( select count(id) from VIEW_product_code AS b where b.p_id in ('780361','780540','780539','780366') and b.product=a.product and b.p_width=a.p_width and b.p_length=a.p_length and b.p_muwen=a.p_muwen ) AS sumshu 
    from VIEW_product_code AS a where p_id in ('780361','780540','780539','780366') 测试过了,这样在网页程序中也不行,而在SQL查询分析器是可以的.
    网页程序是没有问题的,就是上面这个SQL在网页中不能正常运行的.没有提示出错,而是查询不到记录。
      

  2.   

    你的asp的程序有问题了 理论上不可能出现sql语句查询到 asp调用不到的情况
      

  3.   

    我只是换了一条SQL语句,其他的都不改动,一样可以运行的,这说明ASP程序是绝对没有问题的.
      

  4.   

    删除, ( select count(id) from VIEW_product_code AS b where b.p_id in ('780361','780540','780539','780366') and b.product=a.product and b.p_width=a.p_width and b.p_length=a.p_length and b.p_muwen=a.p_muwen ) AS sumshu
    后,
    变成下面的:
    select id,p_code,product,p_product,p_width,p_width_fb,p_length,p_length_fb,p_muwen,printno,p_account  
    from VIEW_product_code AS a where p_id in ('780361','780540','780539','780366')
    可以在ASP中执行了,可是这样不能计算sumshu了。所以问题是出在下面语句:
    , ( select count(id) from VIEW_product_code AS b where b.p_id in ('780361','780540','780539','780366') and b.product=a.product and b.p_width=a.p_width and b.p_length=a.p_length and b.p_muwen=a.p_muwen ) AS sumshu
    这是什么问题呢?该如何修正呢?
      

  5.   

    可是为什么加了, ( select count(id) from VIEW_product_code AS b where b.p_id in ('780361','780540','780539','780366') and b.product=a.product and b.p_width=a.p_width and b.p_length=a.p_length and b.p_muwen=a.p_muwen ) AS sumshu
    在网页程序打开数据库查找不到记录呢?这个部分语句如何修改呢?