Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
ASP! Enough is enough!
Old 03-06-2004, 11:56 AM ASP! Enough is enough!
Zork's Avatar
Extreme Talker

Posts: 201
Trades: 0
Hey,

Porblem: Large Database, to big to fit on a single page.
Complications: The database has one table, and several collums. One for name, one for description, one for link, one for picturelink.
And: It seems to be impossible to page through the recordsets and still have the name lniked to the link collum, a picture source for the picturelink and a normal description.
Oh yeah: Can't use ASP.NET/PHP !!

Any ideas?

P.S. Heres a sample quite similar to what I'll be using. devink.ca/fun/paging.asp
__________________
"Computer games don't affect kids. I mean, if Pacman affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music..."

Last edited by Zork; 03-06-2004 at 11:59 AM..
Zork is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-08-2004, 11:11 AM Try this...
Experienced Talker

Posts: 31
Location: Worchester, MA
Trades: 0
Include ADOVBS.INC to your ASP page. Don't have it? Do a Google for it and you should be able to download a copy. Note:

<!-- #include file="adovbs.inc" -->

Then, set up your DSN and open your connection to your database:

<%
strDSN = "DRIVER=SQL Server;SERVER=SQLSERVER;UID=someusername;PWD=somep assword;"
strDSN = strDSN & "APP=Microsoft® Windows® Operating System;WSID=WEB;DATABASE=SomeDatabase"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strDSN, "someusername", "somepassword"
%>

Now, you need to set up your recordset options:

<%
Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
Dim strOrderBy 'A fake parameter used to illustrate passing them
Dim iRecordsShown 'Loop controller for displaying just iPageSize records
Dim I 'Standard looping var
' Get parameters
iPageSize = 10 ' You could easily allow users to change this

' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
%>

Set up your SQL statement and open the recordset in this manner:

<%
SQL = "SELECT * FROM MyDataBase"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.PageSize = iPageSize
RS.CacheSize = iPageSize
RS.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = RS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
%>

Finally, loop through your recordset in this manner:

<%
If Not RS.EOF Then
RS.AbsolutePage = iPageCurrent
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not RS.EOF

' blah blah, blah, blah, blah
' write out your table, etc as you normally would

iRecordsShown = iRecordsShown + 1
RS.MoveNext
Loop
End If
Set RS = Nothing
%>

And last, but not least, you can dump out some page numbers and navigation (replace scriptname.asp with the appropriate filename):

<%
' show 'Prev' if relevant
If iPageCurrent > 1 Then
%>
<A href="script.asp?page=<%= iPageCurrent - 1 %>">[&lt;&lt; Prev]</A>
<%
End If

' show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<A href="script.asp?page=<%= I %>"><%= I %></A>
<%
End If
Next 'I

' show 'Next' if relevant
If iPageCurrent < iPageCount Then
%>
<A href="script.asp?page=<%= iPageCurrent + 1 %">[Next &gt;&gt;]</A>
<%
End If
%>

Problems, questions? PM me!

Joe
__________________

Please login or register to view this content. Registration is FREE
JoeGoldberg is offline
Reply With Quote
View Public Profile
 
Old 03-09-2004, 08:52 AM
Zork's Avatar
Extreme Talker

Posts: 201
Trades: 0
Wow! Man am I glad somoene finaly helped me out! This is all so great, but one little problem. Im not farmiliar with a DNS connection, do I realy have to put in my server acc stuff? http://www.devink.ca/games/cool/script.asp

catre to take a look?
db name is info.mdb
__________________
"Computer games don't affect kids. I mean, if Pacman affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music..."
Zork is offline
Reply With Quote
View Public Profile
 
Old 03-09-2004, 09:49 AM ASP
Experienced Talker

Posts: 31
Location: Worchester, MA
Trades: 0
Pretty basic ASP stuff...

From what I can see you still haven't included the adovbs.inc file - you can download the file and read about it here:
http://www.asp101.com/articles/john/adovbs/default.asp

Without getting too deep into the directory structure of your webhost, you can use a DSN like the following for an MDB database:
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="
strDSN = strDSN & Server.MapPath("MyDatabase.mdb")

Some good articles on ASP and databases can be found on:

http://www.asp101.com
http://www.4guysfromrolla.com
__________________

Please login or register to view this content. Registration is FREE
JoeGoldberg is offline
Reply With Quote
View Public Profile
 
Old 03-09-2004, 04:46 PM
Zork's Avatar
Extreme Talker

Posts: 201
Trades: 0
It worked! I got it to work! It worked! I got it to work! It worked! I got it to work!
Well, you get the idea. Thank you very much for your time! This will help the developemnt in my site greatly.

My site:

devink.ca

I will see been adding the code you gave me in all of the game pages.
__________________
"Computer games don't affect kids. I mean, if Pacman affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music..."
Zork is offline
Reply With Quote
View Public Profile
 
Old 03-09-2004, 04:57 PM
Experienced Talker

Posts: 31
Location: Worchester, MA
Trades: 0
Glad to help! Good luck!
__________________

Please login or register to view this content. Registration is FREE
JoeGoldberg is offline
Reply With Quote
View Public Profile
 
Old 03-09-2004, 05:13 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
DSN-less connections are also available if you don't want to (or can't) setup a DSN definition. Also, many authors now advocate the use of DSN-less conenctions over DSN.advocate.

Connections strings are used to define a database connection. Below is an example of how to open an Access database connection.


<%
Set connxn = Server.CreateObject("ADODB.Connection")

connxn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\myDatabases\chickenNames.mdb;"
%>
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Reply     « Reply to ASP! Enough is enough!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25812 seconds with 12 queries