Avatar billede guzzie Nybegynder
30. januar 2001 - 22:18 Der er 19 kommentarer og
1 løsning

Next link

hey there

I have an asp page that takes results from my data base, and if there are more than 5 items then it make a \"next 5 links\" link
however when I click on the next link I get a \"page can not be shown error\" :(
so if anyone has a good idea please :)
I would also like to try have my results show as 2 columes instead of one :)

here the script

<html>
<body>
<% Response.Buffer = True

    intPage = Request(\"page\")
    If isNumeric(intPage) = False Or intPage < 1 Then
      intPage = 1
    End If
    Set rs = Server.CreateObject(\"ADODB.RecordSet\")
    strSQL = \"select \" & Request.Form(\"alpha\") & \" from abc\"
    strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"popup.mdb\")
    rs.Open strSQL, strDSN, 1
    If Not (rs.BOF Or rs.EOF) Then
      rs.PageSize = 5
      rs.AbsolutePage = intPage
      intRecCount = rs.PageSize
      intPageCount = rs.PageCount
%>

<table class=\"border\" width=\"300\" align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<tr><td class=\"one\"><table>
<%
  Do While Not rs.EOF And intRecCount > 0
%>
<tr>
<td>
<%=rs(0)%>
</td>
</tr>
<%
  intRecCount = intRecCount - 1
  rs.MoveNext
  Loop
End If
rs.Close
Set rs = Nothing
%>
</table>
<br>
<div align=\"center\">
<%
If Clng(intPage) < Clng(intRecCount) Then
%>
<a href=\"wordinfo.asp?page=<%=intPage - 1%>\">&lt;&lt;&nbsp;Last 2</a>
<%
Else
%>
&lt;&lt;&nbsp;Last 2
<%
End If
%>
&nbsp; - &nbsp;
<%
If Clng(intPage) < Clng(intPageCount) Then
%>
<a href=\"wordinfo.asp?page=<%=intPage + 1%>\">Next 2 &gt;&gt;</a>
<%
Else
%>
Next 2 &gt;&gt;
<%
End If
%>
</div>
</body>
</html>

thanks
Guzzie
Avatar billede tdaugaard Nybegynder
30. januar 2001 - 22:20 #1
First, do you get anything else from IE when you click \"Next\" ? Like \"Internal Server Error\" og something like that ?
Avatar billede tdaugaard Nybegynder
30. januar 2001 - 22:24 #2
This is what i get:

Microsoft OLE DB Provider for ODBC Drivers error \'80040e21\'

ODBC driver does not support the requested properties.

/dictonary_popup/wordinfo.asp, line 15

Avatar billede eagleeye Praktikant
30. januar 2001 - 22:24 #3
first change intPage = Request(\"page\") to
intPage = Request.QueryString(\"page\")
Avatar billede tdaugaard Nybegynder
30. januar 2001 - 22:26 #4
eagleeye:> not neccessary !! Request(\"page\") and Request.QueryString(\"page\") does the exact same thing!
Avatar billede nomiz Nybegynder
30. januar 2001 - 22:27 #5
where are you from? - eksperten.dk is getting \"globalized\"

/vh
Simon
Avatar billede guzzie Nybegynder
30. januar 2001 - 22:27 #6
hmmm
I dont get any server error ?
Avatar billede eagleeye Praktikant
30. januar 2001 - 22:28 #7
OK..

What abbout Request.Form(\"alpha\"), is it possible the Request.Form(\"alpha\") is not present the second time you load the page (wordinfo.asp)?
Avatar billede eagleeye Praktikant
30. januar 2001 - 22:30 #8
Quzzie>> Which line is line 15 ?
Avatar billede eagleeye Praktikant
30. januar 2001 - 23:09 #9
The second time the page load the Request.Form(\"alpha\"), is no avalible ... So you have to add the table name to the location wordinfo.asp?page=2&tname=a !

I have made a example of the wordinfo.asp file. I have also currected a bug, the \"Last Page\" was not displayed as a link:

<% Response.Buffer = True %>
<html>
<head>
<title>something</title>
</head>
<body>
<%

intPage = Request(\"page\")
tableName = Request(\"tname\")

if tableName = \"\" then
tableName = Request.Form(\"alpha\")
end if

If isNumeric(intPage) = False Or intPage < 1 Then
  intPage = 1
End If

Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"select \" & tableName & \" FROM abc\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"popup.mdb\")
rs.Open strSQL, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
  rs.PageSize = 5
  rs.AbsolutePage = intPage
  intRecCount = rs.PageSize
  intPageCount = rs.PageCount
%>

<table class=\"border\" width=\"300\" align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<tr><td class=\"one\"><table>
<%
Do While Not rs.EOF And intRecCount > 0
%>
<tr>
<td>
<%=rs(0)%>
</td>
</tr>
<%
intRecCount = intRecCount - 1
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
%>
</table>
<br>
<div align=\"center\">
<%
If Clng(intPage) > 1 Then
%>
<a href=\"wordinfo.asp?page=<%=intPage - 1%>&tname=<%=tableName%>\">Last page</a>
<%
Else
%>
Last Page
<%
End If
%>

<%
If Clng(intPage) < Clng(intPageCount) Then
%>
<a href=\"wordinfo.asp?page=<%=intPage + 1%>&tname=<%=tableName%>\">Next page</a>
<%
Else
%>
Next Page
<%
End If
%>
</div>
</body>
</html>
Avatar billede eagleeye Praktikant
30. januar 2001 - 23:17 #10
How do you want the two columnes?

1  6
2  7
3  8
4  9
5  10

--OR--

1  2
3  4
5  6
7  8
9  10

?
Avatar billede guzzie Nybegynder
30. januar 2001 - 23:37 #11
hey there eagleeye

that does work thats
with regards to the 2 columes
It doesn´t matter really how but just
as long as there are 2 columes with 5 results in each and that the next link still works :) hehe
Avatar billede guzzie Nybegynder
30. januar 2001 - 23:39 #12
Ahhh ok :)

now im with you :)
colume 1            colume 2
1                    6
2                    7
3                    8
4                    9
5                    10

:)
Guzzie
Avatar billede eagleeye Praktikant
31. januar 2001 - 07:47 #13
Try this one. The pageSize is changed to 10 to get to columns with 5 in each colum:


<% Response.Buffer = True %>
<html>
<head>
<title>something</title>
</head>
<body>
<%

intPage = Request(\"page\")
tableName = Request(\"tname\")

if tableName = \"\" then
tableName = Request.Form(\"alpha\")
end if

If isNumeric(intPage) = False Or intPage < 1 Then
  intPage = 1
End If

Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT \" & tableName & \" FROM abc\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"popup.mdb\")
rs.Open strSQL, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
  rs.PageSize = 10
  rs.AbsolutePage = intPage
  intRecCount = rs.PageSize
  intPageCount = rs.PageCount
%>

<table class=\"border\" width=\"300\" align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">

<tr><th>Column 1</th><th>Column 2</th></tr>
<tr><td>
<table class=\"border\" width=\"300\" align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<%
Do While Not rs.EOF And intRecCount > 5
%>
  <tr><td><%=rs(0)%> </td>
  </tr>
<%
intRecCount = intRecCount - 1
rs.MoveNext
Loop
%>
</table>
</td>
<td>
<table class=\"border\" width=\"300\" align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<%
Do While Not rs.EOF And intRecCount > 0
%>
  <tr><td><%=rs(0)%> </td>
  </tr>
 
<%
intRecCount = intRecCount - 1
rs.MoveNext
Loop
%>
</table>
</td>
</tr>
<%
End If
rs.Close
Set rs = Nothing
%>
</table>
<br>
<div align=\"center\">
<%
If Clng(intPage) > 1 Then
%>
<a href=\"wordinfo.asp?page=<%=intPage - 1%>&tname=<%=tableName%>\">Last page</a>
<%
Else
%>
Last Page
<%
End If
%>

<%
If Clng(intPage) < Clng(intPageCount) Then
%>
<a href=\"wordinfo.asp?page=<%=intPage + 1%>&tname=<%=tableName%>\">Next page</a>
<%
Else
%>
Next Page
<%
End If
%>
</div>
</body>
</html>
Avatar billede guzzie Nybegynder
31. januar 2001 - 11:00 #14
hey there eagle eye :)
thanks for the script
however If a table cell is empty in my database
there also apperars an empty area on my page ?

my page is here try choosing \" i \" from the dropdown to see what i mean
http://www.guzzie.dk/dictonary_popup/

And many thanks again :)
Guzzie
Avatar billede guzzie Nybegynder
31. januar 2001 - 12:49 #15
hey again egale eye :)
dont worry bout that last post
It dosn´t matter now :(
I have just realised I have made a HUGE mistake with my database and am now changing it completely to a much simple solution -- I guess I learnt that lesson at least :) hehe
thanks for you helps :)
Guzzie
Avatar billede eagleeye Praktikant
31. januar 2001 - 13:22 #16
I will take a look at it when I come home from work.
Avatar billede eagleeye Praktikant
31. januar 2001 - 17:51 #17
I have taken the database format from http://www.eksperten.dk/spm/47081.
I can see what the problem was now. But with this new script and you new database it should work.

Filename = wordinfo.asp:

<% Response.Buffer = True %>
<html>
<head>
<title>something</title>
</head>
<body>
<%

numColmOnPage = 2
numRowsPrColm = 5
totalRowsOnPage = numColmOnPage * numRowsPrColm

intPage = Request(\"page\")
tableName = Request(\"tname\")

if tableName = \"\" then
tableName = Request.Form(\"alpha\")
end if

If isNumeric(intPage) = False Or intPage < 1 Then
  intPage = 1
End If

Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT * FROM abc WHERE alpha=\'\" & tableName & \"\';\"
\'strSQL = \"SELECT \" & tableName & \" FROM abc\"
strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"popup.mdb\")
rs.Open strSQL, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
  rs.PageSize = totalRowsOnPage
  rs.AbsolutePage = intPage
  intRecCount = rs.PageSize
  intPageCount = rs.PageCount
%>

<table align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<tr>
<%
for colmCount = 1 to numColmOnPage
    firstTime = 0
    rowsPutIntoColm = 0
    Do While (rowsPutIntoColm < numRowsPrColm)
    If (Not (rs.EOF)) then
      if firstTime = 0 Then
        %>
        <td>
        <table width=\"300\" align=\"center\" valign=\"top\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
        <% 
        Response.Write \"<th>Column \" & colmCount & \"</th>\" \'Insert table header
        firstTime = 1
      end if
      %>
      <tr><td><%=rs(\"ID\")%> <%=rs(\"word\")%></td></tr>
      <%
      rs.MoveNext
    Else
      if firstTime > 0 Then
      %>
        <tr><td>&nbsp;</td></tr>
      <%
      end if
    End If
    \'rs.MoveNext
    rowsPutIntoColm = rowsPutIntoColm + 1
    Loop
    if firstTime > 0 Then
      %>
      </table>
      </td>
      <%
    end if
next
End If
rs.Close
Set rs = Nothing
%>
</tr>
</table>


<br>
<div align=\"center\">
<%
If Clng(intPage) > 1 Then
%>
<a href=\"wordinfo.asp?page=<%=intPage - 1%>&tname=<%=tableName%>\">Last page</a>
<%
Else
%>
Last Page
<%
End If
%>

<%
If Clng(intPage) < Clng(intPageCount) Then
%>
<a href=\"wordinfo.asp?page=<%=intPage + 1%>&tname=<%=tableName%>\">Next page</a>
<%
Else
%>
Next Page
<%
End If
%>
</div>
</body>
</html>
Avatar billede guzzie Nybegynder
31. januar 2001 - 18:13 #18
hey there eagleeye 

that works a treat and my popup still work just fine thank you again
thanks for your hard work.
what bout the other question do you want the points :) heh or shall I close the question ?
Thank you Very much again
Guzzie :)
Avatar billede eagleeye Praktikant
31. januar 2001 - 18:42 #19
You decide.

I think the last script is an answer to this question (46973).  So you should close the other question, you already gave me points for this one :-)
Avatar billede guzzie Nybegynder
31. januar 2001 - 19:09 #20
Thank you again

K and thank you again :)

Guzzie :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester