2012-04-25 73 views
1

我在下面的sql中有一个错误。ASP 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 code..cause我没有去碰它

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

对不起,我不知道ASP编程,但SQL ..

回答

4

您的问题是,在ASP,你问的RecordSet(即来自SQL的结果)为名为""(空字符串)的列。

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

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

LCase(rsFav("site_url") 
+1

谢谢,真棒,它已经帮助 – 2012-04-25 09:45:21