ASP和Access DB - “喜欢”查询问题

时间:2011-03-23 22:26:58

标签: ms-access asp-classic ado

//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运行它。它没有返回和行

2 个答案:

答案 0 :(得分:3)

@ user670111:在你的ASP中,你必须使用%而不是*作为外卡字符。

所以在ASP中重写你的查询

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

答案 1 :(得分:0)

也许pidProduct&的价值观rsCS(“idoptoptgrp”)不是你期望的那样吗?

当你尝试时它是否有效...... ((products.pcprod_ParentPrd=" & 5573 & ") AND (products.pcprod_Relationship LIKE '*" & 441 & "*'));