expublish
Registered User.
- Local time
- Today, 15:18
- Joined
- Feb 22, 2002
- Messages
- 121
Hi all,
1) Great new look forum!
2) I know this is not a direct Access question, but IMO Access and ASP go hand in hand.
My situation is as follows; I have an asp page that simply shows records from a Access DB table or query. They are showing fine. However, I need the ability to be able to show a message 'No matches found' if no records are returned.
My current ASP code is shown below, but when there are no records it doesn't work properly. Can anyone see where I have gone wrong?
TIA
Scott Lyndon.
1) Great new look forum!
2) I know this is not a direct Access question, but IMO Access and ASP go hand in hand.
My situation is as follows; I have an asp page that simply shows records from a Access DB table or query. They are showing fine. However, I need the ability to be able to show a message 'No matches found' if no records are returned.
My current ASP code is shown below, but when there are no records it doesn't work properly. Can anyone see where I have gone wrong?
Code:
<font face="verdana,sans-serif">
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<%
'here is the connection string
Set conn = server.createobject("adodb.connection")
'this connection uses JET 4 it is the prefered method of connecting to an access database
DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../add/data.mdb")
'if you cant use JET then comment out the line above and uncomment the line below
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("../add/data.mdb")
conn.Open DSNtemp
SQL = "Select * from qryart"& qry
pagetot = 10000
const adOpenForwardOnly = 0
const adOpenKeySet = 1
const adOpenDynamic = 2
const adOpenStatic = 3
const adLockReadOnly = 1
const adLockPessimistic = 2
const adLockOptimistic = 3
const adLockBatchOptimistic = 4
Set RS = Server.CreateObject("Adodb.RecordSet")
RS.Open SQL, Conn, adopenkeyset, adlockoptimistic
If RS.EOF Then
%>
</font></p>
<p> <font face="verdana,sans-serif"><table cellspacing=1 border=0 cellpadding=2 width="100%">
<tr>
<td height="13">
<p><font size="2">There are no websites in this
section. Add your web site <a href="../add/addsite.asp">here</a>.</font>
</p>
</td>
</tr>
</table>
</font>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<%ElseIf request("begin") = "" Then
begin = 1
Else
begin = Cint(request("begin"))
End If
tot = ((begin+pagetot)-1)
If tot > RS.RecordCount Then
tot = RS.RecordCount
End If
i = 1
navi = ""
For j = 1 to RS.RecordCount step pagetot
If j <> 1 Then navi = navi & " | "
If j = Cint(begin) Then
navi = navi & "<b>"&i&"</b>"
Else
navi = navi & "<a href="""
navi = navi & Request.ServerVariables("url") & "?begin=" & j & "&which=" & tbl
navi = navi & """>"
navi = navi & i & "</a>"
End If
i = i + 1
Next
i = 1
RS.Move begin - 1
%>
</font></p>
<table cellspacing=1 border=0 cellpadding=1 width="565" height="54">
<tr align="left">
<th align=left width="275">
<div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><%=RS("Title")%></font></div>
</th>
<th width="277" colspan="2">
<div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FF0000"><a href="<%=url%>">
<% url=RS("URL") %>
<%=RS("URL")%></a></font></div>
</th>
</tr>
<%
For x = begin to begin + (pagetot - 1)
If RS.EOF Then exit For
%>
<tr>
<td align=left colspan="3" valign="middle" height="22">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"><%=RS("Description")%></font></td>
</tr>
<%
i = i + 1
RS.MoveNext
Next
%>
</table>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<%
RS.Close
Set RS = nothing
Conn.close
Set Conn = Nothing
%>
</font></p>
</font>
TIA
Scott Lyndon.