ASP SQL查询引发错误

时间:2012-04-25 09:30:55

标签: sql asp-classic

我在以下sql中出错。

    (SELECT shorthand, display, larry_ranking, site_url
FROM larrydb_site_list lsl JOIN larrydb_review lr on
lsl.sid = lr.sid 
WHERE display=true AND niche='regular' 
ORDER BY larry_ranking DESC Limit 2)


UNION


(SELECT shorthand, display, larry_ranking, site_url
FROM larrydb_site_list lsl JOIN larrydb_review lr on
lsl.sid = lr.sid 
WHERE display=true AND niche='regular' AND shorthand='sexier')

我把它放在一行:

    dim rsFav
sSQL = "(SELECT shorthand, display, larry_ranking, site_url FROM larrydb_site_list lsl JOIN larrydb_review lr on lsl.sid = lr.sid WHERE display=true AND niche='regular' ORDER BY larry_ranking DESC Limit 2) UNION (SELECT shorthand, display, larry_ranking, site_url FROM larrydb_site_list lsl JOIN larrydb_review lr on lsl.sid = lr.sid WHERE display=true AND niche='regular' AND shorthand='sexier')"
Set rsFav = objConn.Execute(sSQL)

我收到此错误..

ADODB.Recordset error '800a0cc1' Item cannot be found in the collection corresponding to the requested name or ordinal.
     

/sandbox/inc_fav_sites.asp,第29行

我认为问题出在sql string ....而不是在asp代码中...因为我没碰到它

第29行<a href="http://livecamdeals.com/review.asp?sitename=<%=LCase(rsFav(""))%>"></a>

抱歉,我不知道asp编程但是sql ..

1 个答案:

答案 0 :(得分:4)

你的问题是,在ASP中,你要求一个名为""(空字符串)的列的RecordSet(即从SQL返回的结果)。

显然,你的SQL不会返回这样一个列!!

修复方法是更改​​ASP代码以选择正确的列。例如。选择site_url列:

LCase(rsFav("site_url")