Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollable querys

Status
Not open for further replies.

Trillithium

Technical User
Dec 9, 2000
27
0
0
NL
Hi, im a newbe at ASP and i need help.
Can somebody tell me how to do scrollable querys in an ASP form. I want to scroll in ASP through a database (access) with VBscript, please help me..
 
Hey Trill,

Couple things first...

I think that scrollable query means that you want to gather records and navigate one by one or n by n. If this is the case, you did mention ASP but I would like to verify that you would like to navigate through the records request by request, or do you mean that you would pull down a bunch of records and handle the paging at the client?

smbure
 
<html><head>
<TITLE>dbtablepaged.asp</TITLE>
</head><body bgcolor=&quot;#FFFFFF&quot;>
<!--#INCLUDE VIRTUAL=&quot;/ADOVBS.INC&quot; -->
<%
connectme=&quot;DSN=Student;uid=student;pwd=magic&quot;
sqltemp=&quot;select * from publishers&quot;

' Troubleshooting TIP:
' if you use this code and get an error, for example:
'
' ADODB.Recordset error 800a0cb3
'
' The operation requested by the application is not
' supported by the provider.
'
' You may have a driver that is out of date, see:
' ' for code that will identify what your driver version is
' this script works with Access, SQLserver and Oracle
' with up-to-date drivers

If aduseclient=&quot;&quot; THEN
ref=&quot; response.write &quot;You forgot to include:<br>&quot;
response.write &quot;/adovbs.inc<br>&quot;
response.write &quot;Get the file from <a href='&quot; & ref & &quot;'>&quot; & ref & &quot;<br>&quot;
response.end
END IF

mypage=request(&quot;whichpage&quot;)
If mypage=&quot;&quot; then
mypage=1
end if
mypagesize=request(&quot;pagesize&quot;)
If mypagesize=&quot;&quot; then
mypagesize=10
end if
mySQL=request(&quot;SQLquery&quot;)
IF mySQL=&quot;&quot; THEN
mySQL=SQLtemp
END IF

set rstemp=Server.CreateObject(&quot;ADODB.Recordset&quot;)
rstemp.cursorlocation=aduseclient
rstemp.cachesize=5
tempSQL=lcase(mySQL)
badquery=false
IF instr(tempSQL,&quot;delete&quot;)>0 THEN
badquery=true
END IF
IF instr(tempSQL,&quot;insert&quot;)>0 THEN
badquery=true
END IF
IF instr(tempSQL,&quot;update&quot;)>0 THEN
badquery=true
END IF
If badquery=true THEN
response.write &quot;Not a SELECT Statement<br>&quot;
response.end
END IF

rstemp.open mySQL,connectme
rstemp.movefirst
rstemp.pagesize=mypagesize
maxpages=cint(rstemp.pagecount)
maxrecs=cint(rstemp.pagesize)
rstemp.absolutepage=mypage
howmanyrecs=0
howmanyfields=rstemp.fields.count -1
response.write &quot;Page &quot; & mypage & &quot; of &quot; & maxpages & &quot;<br>&quot;
response.write &quot;<table border='1'><tr>&quot;

'Put Headings On The Table of Field Names
FOR i=0 to howmanyfields
response.write &quot;<td><b>&quot; & rstemp(i).name & &quot;</b></td>&quot;
NEXT
response.write &quot;</tr>&quot;

' Now loop through the data
DO UNTIL rstemp.eof OR howmanyrecs>=maxrecs
response.write &quot;<tr>&quot;
FOR i = 0 to howmanyfields
fieldvalue=rstemp(i)
If isnull(fieldvalue) THEN
fieldvalue=&quot;n/a&quot;
END IF
If trim(fieldvalue)=&quot;&quot; THEN
fieldvalue=&quot;&nbsp;&quot;
END IF
response.write &quot;<td valign='top'>&quot;
response.write fieldvalue
response.write &quot;</td>&quot;
next
response.write &quot;</tr>&quot;
rstemp.movenext
howmanyrecs=howmanyrecs+1
LOOP
response.write &quot;</table><p>&quot;

' close, destroy
rstemp.close
set rstemp=nothing

' Now make the page _ of _ hyperlinks
Call PageNavBar

sub PageNavBar()
' Thanks to Jeff Emrich <jeff.emrich@datafuse.com>
pad=&quot;&quot;
scriptname=request.servervariables(&quot;script_name&quot;)
response.write &quot;<table rows='1' cols='1' width='97%'><tr>&quot;
response.write &quot;<td>&quot;
response.write &quot;<font size='2' color='black' face='Verdana, Arial,Helvetica, sans-serif'>&quot;
if (mypage mod 10) = 0 then
counterstart = mypage - 9
else
counterstart = mypage - (mypage mod 10) + 1
end if
counterend = counterstart + 9
if counterend > maxpages then counterend = maxpages
if counterstart <> 1 then
ref=&quot;<a href='&quot; & scriptname
ref=ref & &quot;?whichpage=&quot; & 1
ref=ref & &quot;&pagesize=&quot; & mypagesize
ref=ref & &quot;&sqlQuery=&quot; & server.URLencode(mySQL)
ref=ref & &quot;'>First</a>&nbsp;:&nbsp;&quot;
Response.Write ref


ref=&quot;<a href='&quot; & scriptname
ref=ref & &quot;?whichpage=&quot; & (counterstart - 1)
ref=ref & &quot;&pagesize=&quot; & mypagesize
ref=ref & &quot;&sqlQuery=&quot; & server.URLencode(mySQL)
ref=ref & &quot;'>Previous</a>&nbsp;&quot;
Response.Write ref
end if
Response.Write &quot;[&quot;
for counter=counterstart to counterend
If counter>=10 then
pad=&quot;&quot;
end if
if cstr(counter) <> mypage then
ref=&quot;<a href='&quot; & scriptname
ref=ref & &quot;?whichpage=&quot; & counter
ref=ref & &quot;&pagesize=&quot; & mypagesize
ref=ref & &quot;&sqlQuery=&quot; & server.URLencode(mySQL)
ref=ref & &quot;'>&quot; & pad & counter & &quot;</a>&quot;
else
ref=&quot;<b>&quot; & pad & counter & &quot;</b>&quot;
end if
response.write ref
if counter <> counterend then response.write &quot; &quot;
next
Response.Write &quot;]&quot;
if counterend <> maxpages then
ref=&quot;&nbsp;<a href='&quot; & scriptname
ref=ref & &quot;?whichpage=&quot; & (counterend + 1)
ref=ref & &quot;&pagesize=&quot; & mypagesize
ref=ref & &quot;&sqlQuery=&quot; & server.URLencode(mySQL)
ref=ref & &quot;'>Next</a>&quot;
Response.Write ref


ref=&quot;&nbsp;:&nbsp;<a href='&quot; & scriptname
ref=ref & &quot;?whichpage=&quot; & maxpages
ref=ref & &quot;&pagesize=&quot; & mypagesize
ref=ref & &quot;&sqlQuery=&quot; & server.URLencode(mySQL)
ref=ref & &quot;'>Last</a>&quot;
Response.Write ref
end if
response.write &quot;<br></font>&quot;
response.write &quot;</td>&quot;
response.write &quot;</table>&quot;
end sub
%>
</body></html>
 
Thanx 4 the reactions. But i allready solved my question. But again, thanx..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top