Jag har en sida där jag kan söka på massa fält och när jag söker så får jag felmess i själva sidnavigeringen. En bit ovanför har jag skrivit ifsats som kollar om den ska plocka ifrån formuläret eller ifrån Querystringen. Den ser ut så här:
<%If Request.QueryString("action") = "search" Then
AdType = Request.Form("typ")
Kat = Request.Form("kat")
County = Request.Form("county")
SearchWord = Request.Form("searchWord")
Else
AdType = Request.QueryString("typ")
Kat = Request.QueryString("kat")
County = Request.QueryString("county")
SearchWord = Request.QueryString("searchWord")
End If%>
<%If (Int(sida)) <> 1 Then%>
<a href="viewAd.asp?<%If Request.QueryString("action") = "search" Then%>action=search&searchWord=<%=SearchWord%>&<%End If%>kat=<%=Kat%>&typ=<%=AdType%>&county=<%=County%>&sida=<%=(Int(sida)-1)%>"><b>Bakåt</b></a> |
<%End If
For Sid = 1 To Sidor
If (Int(Sid)) = (Int(sida)) Then%><b><%=Sid%></b><%Else%> <a href="viewAd.asp?<%If Request.QueryString("action") = "search" Then%>action=search&searchWord=<%=SearchWord%>&<%End If%>kat=<%=Kat%>&typ=<%=AdType%>&county=<%=County%>&sida=<%=Sid%>"><%=Sid%></a> <%End If
Next
If (Int(sida)) <> (Int(Sidor)) Then%>
| <a href="viewAd.asp?<%If Request.QueryString("action") = "search" Then%>action=search&searchWord=<%=SearchWord%>&<%End If%>kat=<%=Kat%>&typ=<%=AdType%>&county=<%=County%>&sida=<%=(Int(sida)+1)%>"><b>Framåt</b></a>
<%End If%>
Tar jag bort själva sidnavigeringen får jag inget felmess.
Feltyp:
Response-objekt, ASP 0185 (0x8002000E)
En av objektets standardegenskaper kan inte hittas.
/jobb/pm/viewAd.asp
<%
If Request.QueryString("action") = "search" Then
AdType = Request.Form("typ")
Kat = Request.Form("kat")
County = Request.Form("county")
SearchWord = Request.Form("searchWord")
Else
AdType = Request.QueryString("typ")
Kat = Request.QueryString("kat")
County = Request.QueryString("county")
SearchWord = Request.QueryString("searchWord")
End If
If (Int(sida)) <> 1 Then
response.write "<a href='viewAd.asp?"
If Request.QueryString("action") = "search" Then
response.write "action=search&searchWord="& SearchWord &"&"
End If
response.write "kat=" &Kat& "&typ=" &AdType& "&county=" &County& "&sida=" &(Int(sida)-1)& "'><b>Bakåt</b></a> |"
End If
For Sid = 1 To Sidor
If (Int(Sid)) = (Int(sida)) Then
response.write "<b>" &Sid& "</b>"
Else
response.write "<a href='viewAd.asp?"
If Request.QueryString("action") = "search" Then
response.write "action=search&searchWord=" &SearchWord& "&"
End If
response.write "kat=" &Kat& "&typ=" &AdType& "&county=" &County& "&sida=" &Sid& "'>" &Sid& "</a>"
End If
Next
If (Int(sida)) <> (Int(Sidor)) Then
response.write " | <a href='viewAd.asp?"
If Request.QueryString("action") = "search" Then
response.write "action=search&searchWord=" &SearchWord& "&"
End If
response.write "kat=" &Kat& "&typ=" &AdType& "&county=" &County& "&sida=" &(Int(sida)+1)& "'><b>Framåt</b></a>"
End If
%>
Uj uj! Det blir massa rader men jag visar väl allt då!
<!--#Include file="top.asp"-->
<%If Request.QueryString("action") = "search" Then
AdType = Request.Form("typ")
Kat = Request.Form("kat")
County = Request.Form("county")
SearchWord = Request.Form("searchWord")
Else
AdType = Request.QueryString("typ")
Kat = Request.QueryString("kat")
County = Request.QueryString("county")
SearchWord = Request.QueryString("searchWord")
End If
Set RS = Server.CreateObject("ADODB.Recordset")
Sidan = Request.QueryString("sida")
If Sidan = "" then
sida = 1
Else
sida = Sidan
End If
RS.CursorLocation = 3
RS.CacheSize = 20
If SearchWord = "" Then
If AdType = "" Then
If County = "" Then
If Kat = "" Then
SQL = "Select * From ads Order By annons_id desc"
Else
SQL = "Select * From ads Where kategori=" & Kat & " Order By annons_id desc"
End if
Else
If Kat = "" Then
SQL = "Select * From ads Where county=" & County & " Order By annons_id desc"
Else
SQL = "Select * From ads Where kategori=" & Kat & " And County=" & County & " Order By annons_id desc"
End if
End If
Else
If County = "" Then
If Kat = "" Then
SQL = "Select * From ads Where typ=" & AdType & " Order By annons_id desc"
Else
SQL = "Select * From ads Where kategori=" & Kat & " And typ=" & AdType & " Order By annons_id desc"
End if
Else
If Kat = "" Then
SQL = "Select * From ads Where typ=" & AdType & " And County=" & County & " Order By annons_id desc"
Else
SQL = "Select * From ads Where kategori=" & Kat & " And typ=" & AdType & " And County=" & County & " Order By annons_id desc"
End if
End If
End If
Else
If AdType = "" Then
If County = "" Then
If Kat = "" Then
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' Order By annons_id desc"
Else
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And kategori=" & Kat & " Order By annons_id desc"
End if
Else
If Kat = "" Then
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And county=" & County & " Order By annons_id desc"
Else
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And kategori=" & Kat & " And County=" & County & " Order By annons_id desc"
End if
End If
Else
If County = "" Then
If Kat = "" Then
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And typ=" & AdType & " Order By annons_id desc"
Else
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And kategori=" & Kat & " And typ=" & AdType & " Order By annons_id desc"
End if
Else
If Kat = "" Then
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And typ=" & AdType & " And County=" & County & " Order By annons_id desc"
Else
SQL = "Select * From ads Where annonstext Like '%" & searchWord & "%' And kategori=" & Kat & " And typ=" & AdType & " And County=" & County & " Order By annons_id desc"
End if
End If
End If
End If
RS.Open SQL, Conn
If Kat <> "" Then
Set Category=Conn.Execute("Select * From category Where kat_id=" & Kat)
End If%>
<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center">
<tr valign="top">
<td bgcolor="<%=BG%>" colspan="6">
<span class="vitrubrik"><b>Visar alla annonser<%If Kat <> "" Then%> i <%=Category("kat")%><%End If%>!</B></span>
</td>
</tr>
<tr valign="top">
<td colspan="6"><!--#Include file="search.asp"--></td>
</tr>
<%If RS.EOF Then%>
<tr valign="top">
<td colspan="6">Det finns inga annonser i denna kategori!</td>
</tr>
<%Else%>
<tr height="25">
<td width="15%"><b><a href="#"><U>Insatt</U></a></b></td>
<td width="5%"> </td>
<td width="43%"><b><a href="#"><U>Annons</U></a></b></td>
<td width="17%" align="right"><b><a href="#"><U>Pris</U></a></b></td>
<td> </td>
<td width="20%"><b><a href="#"><U>Region</U></a></b></td>
</tr>
<%x=0
RS.MoveFirst
RS.PageSize = 20
RS.AbsolutePage = sida
Sidor = RS.PageCount
Do While Not RS.EOF And x < RS.PageSize
Set User=Conn.Execute("Select * From members Where mem_id=" & RS("kund_NR"))
Set County=Conn.Execute("Select * From county Where id=" & RS("county"))%>
<tr height="18">
<td><%=FormatDateTime(RS("datum"),2)%></td>
<td align="center"><%If RS("bild1") <> "" Or RS("bild2") <> "" Or RS("bild3") <> "" Then%><img src="gfx/fotoon.gif"><%End If%></td>
<td><a href="viewAd.asp?ID=<%=RS("annons_ID")%>"><%=RS("rubrik")%></a></td>
<td align="right"><%If RS("pris") <> "" Then%><%=RS("pris")%> kr<%Else%>Ej angett<%End If%></td>
<td> </td>
<td><%=County("lan")%></td>
</tr>
<%x=x+1
RS.MoveNext
Loop%>
</table>
<%If Sidor > 1 Then%>
<table border="0" cellpadding="0" cellspacing="3" style="border-collapse: collapse" width="100%">
<tr>
<td height="22">
<%If (Int(sida)) <> 1 Then%>
<a href="viewAd.asp?<%If Request.QueryString("action") = "search" Then%>action=search&searchWord=<%=SearchWord%>&<%End If%>kat=<%=Kat%>&typ=<%=AdType%>&county=<%=County%>&sida=<%=(Int(sida)-1)%>"><b>Bakåt</b></a> |
<%End If
For Sid = 1 To Sidor
If (Int(Sid)) = (Int(sida)) Then%><b><%=Sid%></b><%Else%> <a href="viewAd.asp?<%If Request.QueryString("action") = "search" Then%>action=search&searchWord=<%=SearchWord%>&<%End If%>kat=<%=Kat%>&typ=<%=AdType%>&county=<%=County%>&sida=<%=Sid%>"><%=Sid%></a> <%End If
Next
If (Int(sida)) <> (Int(Sidor)) Then%>
| <a href="viewAd.asp?<%If Request.QueryString("action") = "search" Then%>action=search&searchWord=<%=SearchWord%>&<%End If%>kat=<%=Kat%>&typ=<%=AdType%>&county=<%=County%>&sida=<%=(Int(sida)+1)%>"><b>Framåt</b></a>
<%End If%>
</td>
</tr>
</table>
<%End If
End If%>
<!--#Include file="bottom.asp"-->
Finns det nåt smartare sätt att göra If-satserna för SQL strängarna? Som det är nu äre ju 60 rader jag har i koden. Inte kul alls med så mycket! Inget av valen är tvingande. Är denna som är om man väljer nåt på alla.
SQL = "Select * From ads Where annonstext Like '%" & StrsearchWord & "%' And
kategori=" & StrKat & " And typ=" & StrType & " And
County=" & StrCounty & " Order By annons_id desc"