opdeling af adresser i 10 stk pr. side samt <stoprec> virker ikke!

Tags:    asp

Har en adresseliste som skal vise 10 adresser af gangen og vise hvilke (i tal) der vises. Den viser alle adresserne på en gang og viser ikke nummeret på stoprec men i stedet 1 heletiden. Har ikke selv lavet koden fra bunden, så har lidt svært ved at overskue den og kan ikke finde fejlen/fejlene!

Siden kan ses her!
www.voltigevkt.dk/adresse/adresselistelist.asp

Håber der er en der kan hjælpe!

Koden er som følgende (har fjernet normal tekst og tabeller for at den ikke bliver endnu længere!):



<style type="text/css">
#lodrettext {
writing-mode:tb-rl;
filter:flipH() flipV() ;
}
</style>
<%
xDb_Conn_Str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("../db/adresseliste.mdb") & ";"
%>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>


<%
displayRecs = 10
recRange = 10
%>

<%
' Get table name
tablename = "[Adresse]"
dbwhere = ""
a_search = ""
b_search = ""
%>



<%
' Get search criteria for basic search
pSearch = Request.QueryString("psearch")
If pSearch <> "" Then
pSearch = replace(pSearch,"'","''")
pSearch = replace(pSearch,"[","[[]")
b_search = b_search & "[Fornavn] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Efternavn] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Adresse] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Postnr] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Bynavn] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Telefon] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Mobiltelefon] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[AfsenderEmail] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Foedselsdag] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Klub] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[GruppeVKT] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Voltistart] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Voltistop] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Barnnavn] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Andet] LIKE '%" & pSearch & "%' OR "
End If
If len(b_search) > 4 Then
b_search = mid(b_search,1,len(b_search)-4)
b_search = "(" & b_search & ")"
End If
%>



<%
'Build search criteria
If a_search <> "" Then
dbwhere = dbwhere & a_search 'advance search
ElseIf b_search <> "" Then
dbwhere = dbwhere & b_search 'basic search
End If

'Save search criteria
If dbwhere <> "" Then
Session("tablename") = tablename
Session("dbwhere") = dbwhere
'reset start record counter
startRec = 1
Session("Adresse_REC") = startRec
Else
If tablename = Session("tablename") Then
dbwhere = Session("dbwhere")
Else
'reset search criteria
dbwhere = ""
Session("dbwhere") = dbwhere
End If
End If

'Get clear search cmd
If Request.QueryString("cmd").Count > 0 then
cmd=Request.QueryString("cmd")
If ucase(cmd) = "RESET" Then
'reset search criteria
dbwhere = ""
Session("dbwhere") = dbwhere
End If
End If

%>


<%
' Load Default Order
DefaultOrder = ""
DefaultOrderType = ""

' Check for an Order parameter
OrderBy = ""
If Request.QueryString("order").Count > 0 Then
OrderBy = Request.QueryString("order")
' Check if an ASC/DESC toggle is required
If Session("Adresse_OB") = OrderBy Then
If Session("Adresse_OT") = "ASC" Then
Session("Adresse_OT") = "DESC"
Else
Session("Adresse_OT") = "ASC"
End if
Else
Session("Adresse_OT") = "ASC"
End If
Session("Adresse_OB") = OrderBy
Session("Adresse_REC") = 1
Else
OrderBy = Session("Adresse_OB")
if OrderBy = "" then
OrderBy = DefaultOrder
Session("Adresse_OB") = OrderBy
Session("Adresse_OT") = DefaultOrderType
End If
End If

' Check for a START parameter
If Request.QueryString("start").Count > 0 Then
startRec = Request.QueryString("start")
Session("Adresse_REC") = startRec
Else
startRec = Session("Adresse_REC")
if not isnumeric(startRec) or startRec = "" then
'reset start record counter
startRec = 1
Session("Adresse_REC") = startRec
End If
End If

' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str

' Build Query
strsql = "select * from [Adresser]"

If dbwhere <> "" Then
strsql = strsql & " WHERE " & dbwhere
End If

if OrderBy <> "" then
strsql = strsql & " ORDER BY [" & OrderBy & "] " & Session("Adresse_OT")
end if

'response.write strsql

set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
totalRecs = rs.RecordCount
%>

<%
'Avoid starting record > total records
if clng(startRec) > clng(totalRecs) then
startRec = totalRecs
end if
'Set the last record to display
stopRec = startRec + displayRecs - 1

'Move to first record directly for performance reason
recCount = startRec - 1
if not rs.eof then
rs.movefirst
rs.move startRec - 1
end if

recActual = 0
Do While (NOT rs.EOF) AND (recCount < stopRec)
recCount = recCount + 1
If Clng(recCount) >= Clng(startRec) Then
recActual = recActual + 1 %>
<%
'set row color
bgcolor="#FFFFFF"
%>
<%
' Display alternate color for rows
If recCount mod 2 <> 0 Then
bgcolor="#F5F5F5"
End If
%>

<%
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2

if totalRecs > 0 then

' Find out if there should be Backward or Forward Buttons on the table.
If startRec = 1 Then
isPrev = False
Else
isPrev = True
PrevStart = startRec - displayRecs
If PrevStart < 1 Then PrevStart = 1 %> <strong><a href="Adresselistelist.asp?start=<%=PrevStart%>"><font size="-1">[<<Forrige]</font></a></strong>
<%
End If

' Display Page numbers
If (isPrev OR (NOT rs.EOF)) Then
If (NOT isPrev) Then Response.Write "<HR SIZE=1>"
x = 1
y = 1

dx1 = ((startRec-1)\\(displayRecs*recRange))*displayRecs*recRange+1
dy1 = ((startRec-1)\\(displayRecs*recRange))*recRange+1
If (dx1+displayRecs*recRange-1) > totalRecs then
dx2 = (totalRecs\\displayRecs)*displayRecs+1
dy2 = (totalRecs\\displayRecs)+1
Else
dx2 = dx1+displayRecs*recRange-1
dy2 = dy1+recRange-1
End If

While x <= totalrecs
If x >= dx1 and x <= dx2 Then
If Clng(startRec) = Clng(x) Then %>
<strong><font size="-1"><%=y%></font></strong> <% Else %> <strong><a href="Adresselistelist.asp?start=<%=x%>"><font size="-1"><%=y%></font></A></strong> <% End If
x = x + displayRecs
y = y + 1
elseif x >= (dx1-displayRecs*recRange) and x <= (dx2+displayRecs*recRange) then
if x+recRange*displayRecs < totalRecs then %> <strong><a href="Adresselistelist.asp?start=<%=x%>"><font size="-1"><%=y%>-<%=y+recRange-1%></font></a></strong> <% else
ny=(totalRecs-1)\\displayRecs+1
if ny = y then %> <strong><a href="Adresselistelist.asp?start=<%=x%>"><font size="-1"><%=y%></font></a></strong> <% else %> <strong><a href="Adresselistelist.asp?start=<%=x%>"><font size="-1"><%=y%>-<%=ny%></font></a></strong> <% end if
end if
x=x+recRange*displayRecs
y=y+recRange
else
x=x+recRange*displayRecs
y=y+recRange
End If
Wend
End If

' Next link
If NOT rs.EOF Then
NextStart = startRec + displayRecs
isMore = True %> <strong><a href="Adresselistelist.asp?start=<%=NextStart%>"><font size="-1">[Næste >>]</font></a></strong>
<% Else
isMore = False
End If %> <hr size="1"> <h4>
<% If stopRec > recCount Then stopRec = recCount %>
<font size="-1">Adresser fra </font><font size="-1"><%= startRec %> til <%= stopRec %> af ialt <%= totalRecs %></font>
<% Else %>
<br>
<br>
<font color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">Der
er desværre ikke fundet nogle ved søgning!</font> <br>
<br>
<% End If %>
<%

rs.MoveNext
Loop

rs.Close
Set rs = Nothing

conn.Close
Set conn = Nothing %>






t