View Single Post
  #1 (permalink)  
Old June 20th, 2009, 09:20 PM
rhussain rhussain is offline
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Post Data navigation from an Access database

I am using classic ASP to access fields from and access database. I am using the following code and it works but one of the fields in the database is going to be a URL and this program does not access it as a URL. Instead it accesses it as a text item. How can I amke it access the URL and show it as such in my table that I am retrieving from the data file?

I am sure there is a simple solution. But could someone help me. I have spent a lot of time on this already.

The code is as follows. I got it from one Mr Faisal Khan. The database that goes with it is not shown.

<% Option Explicit
' ADO constants used in this page
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3
%>
<html>
<head>
<style>
body { font-family : Verdana; font-size : 8pt; }
a { font-family : Verdana; font-size : 8pt; text-decoration : none; }
</style>
</head>
<body>
<%
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("paging.mdb")

Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

rs.PageSize = 1
rs.CacheSize = 5
rs.CursorLocation = adUseClient

rs.Open "Names", connStr, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect


If Len(Request("pagenum")) = 0 Then
rs.AbsolutePage = 1
Else
If CInt(Request("pagenum")) <= rs.PageCount Then
rs.AbsolutePage = Request("pagenum")
Else
rs.AbsolutePage = 1
End If
End If

Dim abspage, pagecnt
abspage = rs.AbsolutePage
pagecnt = rs.PageCount

If Not rs.EOF Then
Response.Write "PageCount : " & rs.PageCount & "<br>" & vbcrlf
Response.Write "Absolute Page : " & rs.AbsolutePage & "<br>" & vbcrlf

Response.Write "Total number of records : " & rs.RecordCount & "<br><br>" & vbcrlf

Dim fldF, intRec ,x

Response.Write "<table border=1 align=center cellpadding=3 cellspacing=0><thead><tr>"
For Each fldF in rs.Fields
Response.Write "<td>" & fldF.Name & "</td>"
Next
Response.Write "</tr></thead><tbody>"

For intRec=1 To rs.PageSize
If Not rs.EOF Then
Response.Write "<tr>"
For Each fldF in rs.Fields
response.write "<td>" & "<a href=" & <%rs.Fields("URLString")%> & " ">" " & "ab" & "</a>"


' Response.Write "<td>" & "<a href="" & fldf.value & " "> ab </a>" &
"</td>"

Next
Response.Write "</tr>"
rs.MoveNext
End If
Next
Response.Write "</tbody></table><p>"

' Now showing first, next, back, last buttons.
Response.Write "<div align=""center"">" & vbcrlf
Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=1"">First Page</a>"
Response.Write "&nbsp;|&nbsp;"

If abspage = 1 Then
Response.Write "<span style=""color:silver;"">Previous Page</span>"
Else
Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage - 1 & """>Previous Page</a>"
End If

Response.Write "&nbsp;|&nbsp;"

If abspage < pagecnt Then
Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & abspage + 1 & """>Next Page</a>"
Else
Response.Write "<span style=""color:silver;"">Next Page</span>"
End If
Response.Write "&nbsp;|&nbsp;"
Response.Write "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?pagenum=" & pagecnt & """>Last Page</a>"
Response.Write "</div>" & vbcrlf

Else
Response.Write "No records found!"
End If

rs.Close
Set rs = Nothing
%>
</body>
</html>