Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: ADO Paging error


Message #1 by "Ken Dowling" <ken.dowling@o...> on Tue, 16 Oct 2001 12:32:11
Hi All,



I am having problems with paging using a small Access 2000 database. I 

implemented a similar system a few months ago and it worked very well. 



I was hoping if ye could look at the code and see if errors can be 

spotted. I think the main problem is the WHERE statement in the SQL 

string. I have included the code below. 



Code 1 shows part of the form page where the user chooses from a drop down 

box. 



Code 2 processes this script and deals with all the Response.Write outputs.

 

It works fine to a point i.e. Brings back the data, shows the number of 

records and pages returned. However, the [Next], [Last] etc. links refuse 

to work.



I'd really appreciate any comments.



TIA,



Ken Dowling



Code 1:



<FORM NAME="add" ACTION="asp/shipping-db.asp" METHOD=GET onSubmit="return 

validateForm()">



<SELECT NAME="mdo">

<OPTION VALUE='1'>----------- Select A Shipping Service -----------

<OPTION VALUE=ship_broking='Yes'>Ship Broking<OPTION 

VALUE=Liner_and_Port_Agency='Yes'>Liner and Port Agency<OPTION 

VALUE=Ship_Management='Yes'>Ship Management<OPTION 

VALUE=Maritime_Insurance='Yes'>Maritime Insurance<OPTION 

VALUE=Ship_Financing_and_Banking='Yes'>Ship Financing and Banking<OPTION 

VALUE=Ship_Owners_and_Operators='Yes'>Ship Owners and Operators<OPTION 

VALUE=Harbour_and_Port_Authorities='Yes'>Harbour and Port Authorities

<OPTION VALUE=Maritime_Law_and_Legal_Services='Yes'>Maritime Law and Legal 

Services<OPTION VALUE=Maritime_and_Water_Related_Training='Yes'>Maritime 

and Water Related Training<OPTION VALUE='ID>0 order by company'>All 

Shipping Services : Sorted from A to Z

</SELECT>



Code 2:



<%

'Read in form values

Dim intimdo

Dim iPageSize

Dim strPageCurrent

Dim strPageCount

intimdo = Request.QueryString("mdo")



If request("d1") <> ""Then Session("d1") = request("d1")



'Get the parameters from the dropdown box on the form page.

iPageSize = Session("d1")

If request("page") = "" Then

strPageCurrent = 1

Else

strPageCurrent = CInt(Request("Page"))

End If



Dim strSQL, objRS



strSQL = "select 

Company,Title,First_Name,Last_Name,Job_Title,Address1,Address2,City,County,

Phone,Fax,Mobile,Email,Web_Site,Short_Description,Ship_Broking,Liner_and_Po

rt_Agency,Ship_Management,Maritime_Insurance,Ship_Financing_and_Banking,Shi

p_Owners_and_Operators,Harbour_and_Port_Authorities,Maritime_Law_and_Legal_

Services,Maritime_and_Water_Related_Training from mdo where "& intimdo & ""



Set objRS = Server.CreateObject("ADODB.Recordset")



'Set cursor location and page size

objRS.CursorLocation = adUseClient

objRS.PageSize = iPageSize



'Open the Recordset with a Keyset cursor

objRS.Open strSQL, objConn, adOpenKeySet



'Get the count of the pages using the given page size

strPageCount = objRS.PageCount



if strPageCount = False then

Response.Redirect "enfoerror2.htm"

end if



'Move to the selected page

objRS.AbsolutePage = strPageCurrent



if objRS.RecordCount>1 then

Response.Write "<b><font color=""#2D9AC5""><font face=""Verdana, Arial, 

Helvetica, sans-serif""> " & objRS.RecordCount & " records were returned. 

</b></font>&nbsp;"

end if



if objRS.RecordCount=1 then

Response.Write "<b><font color=""#2D9AC5""><font face=""Verdana, Arial, 

Helvetica, sans-serif""> " & objRS.RecordCount & " record was returned. 

</b></font>&nbsp;"

end if



'Start output with a page X of N

Response.Write "<b><font color=""#006666""><font face=""Verdana, Arial, 

Helvetica, sans-serif""><B>Page "

Response.Write strPageCurrent

Response.Write " of "

Response.Write strPageCount

Response.Write ".</B></FONT><BR><BR>" & vbCrLf



Dim sURL

sURL = "shipping-db.asp?page=" & strPageCurrent + 1  & "&" & intimdo



Dim ssURL

ssURL = "shipping-db.asp?page=" & strPageCurrent - 1 & "&" & intimdo



Dim sssURL

sssURL = "shipping-db.asp?page=1" & "&" & intimdo



Dim ssssURL

ssssURL = "shipping-db.asp?page=" & strPageCount & "&" & intimdo



'Show "Previous" and "Next" links which navigate between pages

If strPageCurrent < strPageCount Then

Response.Write("<a href=""" & sURL & """>[Next Page]</a>") & " "

End If

If strPageCurrent <> 1 Then

Response.Write("<a href=""" & ssURL & """>[Previous Page]</a>") & " "

End If

If strPageCurrent <> 1 Then

Response.Write("<a href=""" & sssURL & """>[First Page]</a>") & " "

End If

If strPageCurrent < strPageCount Then

Response.Write("<a href=""" & ssssURL & """>[Last Page]</a><br>") & " "



End If



Do While Not objRS.EOF

 
Message #2 by gbrown@c... on Tue, 16 Oct 2001 13:07:00
Hi



Suggest you first of all do a response.write strSQL and make sure it is 

giving you what you expect. On mine I also end the string with ;



Is it all choices that fail or just some?



If you want to do another post with some more details will have another 

look!



Regards

Graham









> Hi All,

> 

> I am having problems with paging using a small Access 2000 database. I 

> implemented a similar system a few months ago and it worked very well. 

<snipped>


  Return to Index