Empty recordset...
var ska jag lägga in nedanstående kodsnutt för att få ett felmeddelande ífall sökningen inte gav något resultat:If DBForum.EOF Then
Response.Write \"Sökningen gav inga träffar\"
Else
End If
<-----------kodexempel -------------->
<!--#include file=\"settings.inc\"-->
<html>
<head>
<title>Öppet forum...</title>
<!--#include file=\"stilar.inc\"-->
<%
\'----------------------------------------------------------------
\' Skapa subben som skriver ut navigations-menyn
\'----------------------------------------------------------------
Sub PageNavigation(nPage, nTotPages)
Dim strScriptName \' AS String
Dim I \' AS Integer
strScriptName = Request.ServerVariables(\"SCRIPT_NAME\")
\'--------------------------------------------------------------------
\' If not first page, then show previous
\'--------------------------------------------------------------------
If CInt(nPage) <> 1 Then
Response.Write(\"<a href=\"\"\" & strScriptName & \"?\" & \"page=\" & nPage - 1 & \"\"\" class=\'ex2\'><font class=rodLank>Föregående</font></a> - \")
End If
\'--------------------------------------------------------------------
\' Loop through total pages and create links
\' to all pages in recordset
\'--------------------------------------------------------------------
For I = 1 TO nTotPages
If CInt(I) <> CInt(nPage) Then
Response.Write(\"<a href=\"\"\" & strScriptName & \"?\" & \"page=\" & I & \"\"\" class=\'ex2\'><font class=rodLank>\" & I & \"</font></a> \")
Else
Response.Write \"<span class=\'aktiv\'>[\" & I & \"]</span> \"
End If
Next
\'--------------------------------------------------------------------
\' If Not current page is the last page
\' then show next page
\'--------------------------------------------------------------------
If CInt(nPage) <> CInt(nTotPages) Then
Response.Write(\" - <a href=\"\"\" & strScriptName & \"?\" & \"page=\" & nPage + 1 & \"\"\" class=\'ex2\'><font class=rodLank>Nästa</font></a>\")
End If
End Sub
\'----------------------------------------------------------------
\' Avsluta subben
\'----------------------------------------------------------------
%>
<script type=\"text/javascript\" language=\"JavaScript\">
// Define the location of count.asp
// Using a path, you may use this code in any subfolder
var file=\'/stats/count.asp\';
var d=new Date();
var s=d.getSeconds();
var m=d.getMinutes();
var x=s*m;
f=\'\' + escape(document.referrer);
if (navigator.appName==\'Netscape\'){b=\'NS\';}
if (navigator.appName==\'Microsoft Internet Explorer\'){b=\'MSIE\';}
if (navigator.appVersion.indexOf(\'MSIE 3\')>0) {b=\'MSIE\';}
u=\'\' + escape(document.URL); w=screen.width; h=screen.height;
v=navigator.appName;
fs = window.screen.fontSmoothingEnabled;
if (v != \'Netscape\') {c=screen.colorDepth;}
else {c=screen.pixelDepth;}
j=navigator.javaEnabled();
info=\'w=\' + w + \'&h=\' + h + \'&c=\' + c + \'&r=\' + f + \'&u=\'+ u + \'&fs=\' + fs + \'&b=\' + b + \'&x=\' + x;
document.write(\'<img src=\"\' + file + \'?\'+info+ \'\" width=0 height=0 border=0>\');
</script>
<script language=\"JavaScript\" src=\"bildbyte.js\"></script>
</head>
<body bgcolor=\"<%=bgcolor%>\" background=\"hoger.gif\">
<div id=\"Layer1\" style=\"position:absolute; left:10px; top:10px; width:400px; height:500px; z-index:1\">
<table bgcolor=\"white\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
<tr bgcolor=\"#FFFFFF\">
<td colspan=\"3\" background=\"bilder/ram_uppe.gif\"><img src=\"bilder/1pix.gif\" width=\"1\" height=\"38\" border=\"0\" alt=\"\"></td>
</tr>
<tr>
<td rowspan=\"1\" background=\"bilder/ram_vanster.gif\"><img src=\"bilder/1pix.gif\" width=\"22\" height=\"1\" border=\"0\"alt=\"\"></td>
<td><a href=\"write.asp\"><img src=\"bilder/forum_write.gif\" width=\"91\" align=\"right\" height=\"11\" border=\"0\" alt=\"\"></a><br><br>
<table bgcolor=\"White\" border=\"0\" width=\"382\" cellpadding=\"0\" cellspacing=\"0\">
<tr bgcolor=\"#B7A0A8\">
<td width=\"45%\"><b>Rubrik</b></td>
<td nowrap><b>Postat av </b></td>
<td nowrap><b>Datum</b></td>
<td nowrap><b>Svar</b></td>
</tr>
<tr><td><img src=\"bilder/1pix.gif\" width=\"10\" height=\"5\" border=\"0\" alt=\"\"></td></tr>
<%
\'----------------------------------------------------------------
\' Kolla vilken sida man är på
\'----------------------------------------------------------------
intPage = Request.QueryString(\"page\")
If intPage = \"\" Then intPage = 1
\'----------------------------------------------------------------
\' Öpnna forum.db och lista alla inlägg som är förstameddelande
\'----------------------------------------------------------------
Set DBForum = Server.CreateObject(\"ADODB.Recordset\")
Set Connection = Server.CreateObject(\"ADODB.Connection\")
query = Request.form(\"querybox\")
Connection.Open \"Driver={Microsoft Access Driver (*.mdb)}; DBQ=\" & Server.MapPath(\"forum.mdb\") & \";pwd=;\"
\' set SQL
sql = \"Select * From forum Where (By Like \'%\" & query & \"%\')\"
sql = sql & \"OR (subject LIKE \'%\" & query & \"%\')\"
sql = sql & \"OR (body LIKE \'%\" & query & \"%\') order by datetime desc\"
\'----------------------------------------------------------------
\' Grab records from database
\'----------------------------------------------------------------
With DBForum
.CacheSize = 5
.PageSize = pagesize
.Open SQL, Connection, 3, 1
.AbsolutePage = intPage
.PageSize = pagesize
End With
intCount = DBForum.RecordCount
intTotPages = DBForum.PageCount
Do Until DBForum.EOF or nRecCount >= DBForum.PageSize
%>
<tr onMouseOver=\"this.style.backgroundColor=\'<%=trover%>\';\" onMouseOut=\"this.style.backgroundColor=\'\';\">
<td><% if DBForum(\"answers\") >4 then%><img src=\"bilder/hett.gif\" width=\"12\" align=\"absbottom\" height=\"13\" border=\"0\" alt=\"\">
<% else%><% If DBForum(\"sistapost\") > request.cookies(\"sisthar\") then %><img src=\"bilder/aktuellt.gif\" align=\"absbottom\" width=\"10\" height=\"11\" border=\"0\" alt=\"\"><% Else %><img src=\"bilder/inaktuellt.gif\" align=\"absbottom\" width=\"10\" height=\"11\" border=\"0\" alt=\"\"><% End If %><% End If %><a href=\"show.asp?id=<%=DBForum(\"Parent\")%>\"> <%=DBForum(\"Subject\")%></a></td>
<td nowrap><%=DBForum(\"By\")%> </td>
<td nowrap><%=Mid(DBForum(\"DateTime\"),1,10)%> </td>
<td nowrap align=\"center\"><%=DBForum(\"answers\")%></td>
</tr>
<%
nRecCount = nRecCount + 1
DBForum.MoveNext
Loop
DBForum.Close
Set DBForum = nothing
Connection.Close
%>
</table>
<br><hr noshade size=1 color=black>
<span class=\"tdtext\"><%Call PageNavigation(intPage, intTotPages)%></span><br>
<hr noshade size=1 color=black>
<a href=\"default.asp\" onMouseover=\"rollIn(\'button_3_\')\" onMouseout=\"rollOut(\'button_3_\')\"><img src=\"bilder/hem.gif\" border=\"0\" name=\"button_3_\" vspace=\"1\"></a><br>
<a href=\"java script:history.back();\" onMouseover=\"rollIn(\'button_4_\')\" onMouseout=\"rollOut(\'button_4_\')\"><img src=\"bilder/tillbaka.gif\" border=\"0\" vspace=\"1\" name=\"button_4_\"></a>
</td>
<td rowspan=\"1\" background=\"bilder/ram_hoger.gif\"><img src=\"bilder/1pix.gif\" width=\"26\" height=\"1\" border=\"0\" alt=\"\"></td>
</tr>
<tr>
<td colspan=\"3\" background=\"bilder/ram_nere.gif\"><img src=\"bilder/1pix.gif\" width=\"1\" height=\"38\" border=\"0\" alt=\"\"></td>
</tr>
</table>
</div>
<div id=\"Layer4\" style=\"position:absolute; left:440px; top:12px; width:140pxx; height:195px; z-index:4\">
<img src=\"bilder/inforuta.gif\" width=\"136\" height=\"185\" border=\"0\" alt=\"\">
</div>
</body>
</html>
<------------------slut på koden ------------------>
