2011-03-23 74 views
0
//ACCESS 
SELECT DISTINCT products.imageUrl FROM products WHERE ((products.pcprod_ParentPrd=5573) AND (products.pcprod_Relationship LIKE '*441*')); 

//ASP 
SELECT DISTINCT products.imageUrl FROM products WHERE ((products.pcprod_ParentPrd="&pidProduct&") AND (products.pcprod_Relationship LIKE '*"&rsCS("idoptoptgrp")&"*')); 

此查詢在手動運行Access數據庫中的查詢時起作用。但是當我從ASP運行它。它不返回並且行ASP和Acess DB - 「Like」查詢問題

回答

3

@ user670111:在您的ASP中,您必須使用%而不是*作爲通配符。

因此重寫ASP查詢作爲

SELECT DISTINCT products.imageUrl FROM products WHERE (products.pcprod_ParentPrd = " & pidProduct & ") AND (products.pcprod_Relationship LIKE '%" & rsCS("idoptoptgrp") & "%') 
+0

這是假設在ASP你使用ADO/OLEDB執行的SQL。如果你使用DAO(我不太可能,我知道),*通配符會起作用。 – 2011-03-27 21:35:35

+1

@ David-W-Fenton:這與用戶670111迴應說使用我的答案解決問題的可能性相當。 ;-P – stealthyninja 2011-03-27 21:46:00

+1

謝謝先生!我正在使用ADO/OLEDB – danniel 2011-03-31 19:02:46

0

也許& RSCS(「idoptoptgrp」)是不是你期待它成爲pidProduct的價值?

請問,當你嘗試它的工作... ((products.pcprod_ParentPrd=" & 5573 & ") AND (products.pcprod_Relationship LIKE '*" & 441 & "*'));