1

我在以下 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 字符串中......不是在 asp 代码中......因为我没有碰它

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

对不起,我不知道asp编程但是sql ..

4

1 回答 1

4

您的问题是,在 ASP 中,您向 RecordSet(即从 SQL 返回的结果)询问名为""(empty-string) 的列。

很明显,你的SQL没有返回这样的列!!

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

LCase(rsFav("site_url")
于 2012-04-25T09:39:49.977 回答