Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_ado_rds thread: Recordsets and moving.?


Message #1 by "John Doe" <j.shutt@b...> on Fri, 19 Apr 2002 20:00:02
Right i have a recordset, and it is displayed in a form, what i need is 
when the users makes their selection and clicks the submit button is for 
the recordset to movenext and be displayed on the screen.

the code below is an attempt at this, but all i seem to get is the post 
back, but instead of moving next, it appears to be re-opening the 
recordset and starting again.   Do i need to cache somewhere or setup 
pagecounts or something.  


<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>CP2023 - Computer Networks</TITLE>
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
</SCRIPT>
</HEAD>
<BODY>
<%
dim Conn, Questions, Conn2, Answers
dim MyArray(20)
dim varBook 
varBook = 1 
Set Cmd = Server.CreateObject("ADODB.Command")
Set Conn = Server.CreateObject("ADODB.Connection")
Set Questions = Server.CreateObject("ADODB.Recordset")
Set Answers = Server.CreateObject("ADODB.Recordset")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''
Conn.CursorLocation = 3
Conn.Open "Provider =Microsoft.Jet.OLEDB.4.0;" &_
		  "Data Source = 
C:\Inetpub\wwwroot\test\datastore\questions.mdb;" &_
		  "Persist Security Info=False" ' CONNECTION TO DATABASE

cmd.CommandType = 2

strSQL = "SELECT * FROM questions" 'QUESRY THE TABLE QUESTION FOR ALL 
RECORDS
Questions.CacheSize = 10
Questions.CursorType = 3
Questions.CursorLocation = 3
Questions.LockType = 3

Questions.Open strSQL, Conn 'OPEN RECORDSET



''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''

strSQL = "SELECT * FROM student" 'QUESRY THE TABLE ANSWERS FOR ALL RECORDS

Answers.Open strSQL, Conn, adOpenDynamic 'OPEN RECORDSET


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''
Curnq = questions("Question Number")
MyArray(Curnq)= Request.Form("Answer")
Response.Write Myarray(Curnq)

%>
<H2>You are currently on question number <%Response.Write Questions
("Question Number")%><BR><BR><BR>

<%Response.Write Questions("Question")%><BR>



<form action="test.asp" method="post"  name=Form>  
<p><input TYPE="radio" NAME="Answer" VALUE="A"><%Response.Write Questions
("Answer A")%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="B"><%Response.Write Questions
("Answer B")%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="C"><%Response.Write Questions
("Answer C")%></p>
<p><input TYPE="radio" NAME="Answer" VALUE="D"><%Response.Write Questions
("Answer D")%></p>
<input type="submit" Value ="Forwards" onclick = <%Questions.MoveNext%
>></form></H2>

</BODY>
</HTML>
Message #2 by lingasamyk@h... on Fri, 26 Apr 2002 06:09:27
Hi 

You can achieve this using the properties (PageSize and AbsolutePage) of 
recordset

Set the pagesize of the record set that is the number of records to be 
displayed at a time 

Rs.PageSize = Number of records to be displayed

Set the AbsolutePage property

Rs.AbsolutePage = The set of records to be displayed

For eg if you set the pagesize property as 2
and if you want to display the 3rd and 4th records of the recordset

you have to set Rs.AbsolutePage = 2, then if you traverse in the recordset 
you will have the 3rd and 4th records

Regards,
Lingasamy K

  Return to Index