PaceMedlem sedan juni 20015 947 inlägg Sökfunktion till forum.
Fel:
Item cannot be found in the collection corresponding to the requested name or ordinal.
SELECT Forum.*, Reply.*, Topics.* FROM (Forum LEFT JOIN Topics ON Forum.Forum_ID = Topics.Forum_id) LEFT JOIN Reply ON Topics.Topic_ID = Reply.Topic_ID WHERE (Forum.F_Description LIKE '%hej%' OR Reply.R_Message Like '%hej%' OR Topics.T_Message LIKE '%hej%' ) ORDER BY topics.topic_id
Felet uppstår när jag försöker hämta följande rs: rs("topic_id")
------------------
Peter D
LarsGMedlem sedan dec. 200012 465 inlägg Det verkar ju skumt. Du får nog visa mer kod, du kanske blandar ihop recordseten?
------------------
essentitia preter non sans multiplicandum
PaceMedlem sedan juni 20015 947 inlägg Okej, skickar med hela faderullan :)
keywords = Split(dbSecure(Request.Form("search")), " ")
keycnt = Ubound(keywords)
SQL ="SELECT Forum.*, Reply.*, Topics.* FROM (Forum LEFT JOIN Topics "
SQL = SQL & "ON Forum.Forum_ID = Topics.Forum_id) LEFT JOIN Reply ON Topics.Topic_ID = Reply.Topic_ID "
SQL = SQL & "WHERE "
if Request.Form("forum") <> 0 then
SQL = SQL & "Forum.Forum_ID = " & Request.Form("forum") & " AND "
End If
SQL = SQL & "("
if Request.Form("searchdate") <> 0 then
dt = cint(Request.Form("searchdate"))
SQL = SQL & "T_date > #" & dateadd("d", -dt, now) & "#) AND ("
End if
cnt = 0
For Each word In keywords
SQL = SQL & "Forum.F_Description LIKE '%" & word & "%' OR Reply.R_Message LIKE '%" & _
word & "%' OR Topics.T_Message LIKE '%" & _
word & "%' "
If cnt < keycnt Then SQL = SQL & Request.Form("andor")
cnt = cnt + 1
Next
SQL = SQL & ") ORDER BY topics.topic_id"
mypage = Request("whichpage")
If mypage = "" then mypage = 1
'************************************************
' SQL:en genererar fel ibland om man söker på vissa ord!!
response.write "<FONT FACE=""courier new"" SIZE=2>" & SQL & "<P>"
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open ConnString
Set rs = Connection.Execute(SQL)
If rs.Eof or rs.Bof then
Response.Write "<FONT FACE=""" & DefaultFontFace & """ SIZE=2>" & _
"<DIV ALIGN=""center"">Inga träffar hittades.</CENTER></FONT>"
Else
Response.Write "<FONT FACE=""" & DefaultFontFace & """ SIZE=2>" & _
"Visar sökresultat.</FONT>"
%>
rec_id = ""
Do until rs.Eof
[red]If rec_id <> rs("topic_id") Then
Response.Write "<TD BGCOLOR='...
"<font color='" & ForumLinkColor...
"<td bgcolor='" & ...
"<td bgcolor='" & ForumCellColor & "' align=...
"</tr>"
End if
rec_id = rs("topic_id")
rs.MoveNext
Loop
' Rensa upp
rs.Close
Connection.Close
Set rs = nothing
Set Connection = nothing
[r] Den röda är felraden.
[r2] Lite väl långa rader kanske =)
------------------
Peter D
[Redigerat av Pace den 09 aug 2001]
[Redigerat av Pace den 09 aug 2001]
LarsGMedlem sedan dec. 200012 465 inlägg Jag förstår inte riktigt. Det borde till och med finnas två förekomster av den kolumnen i recordsetet (borde inte ha någon betydelse).
Om du skriver
select * from ...
i stället? Blir det bättre?
Du kan ju också testa med att namnge fälten
select topic.topic_id as topic_id,
forum.description as ...
Tyvärr, så har jag ingen förklaring om vad som är problemet.
------------------
essentitia preter non sans multiplicandum
PaceMedlem sedan juni 20015 947 inlägg He, inget av det funkade... har aldrig varit med om något sånt här innan, kanske är det databasen som spökar?
------------------
Peter D