Hi all,
I am doing a simple program which display random records to students.The student table has the following fields(Access Database)
Code:
1.Studentid-Number
2.Studentname-Text
3.Class-Text
4.Ans-Text
and Question table as
Code:
1.Questionid-Number
2.Questions-Text
Now What i am trying to do is , when the first time is student is login,he wil be shown a random record from the question and his answered wil be stored in the Ans field of the student table with column separeated.The he will be redirected to the same page with one new question.This question should not be in the Ans Field, and must be randomly generated.I am using this code.But this not working.Can some body help.

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #INCLUDE FILE="Connection.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Multiplication Competition</title>
<style type="text/css">
<!--
body {
	background-image: url(images/MathsCompBGB.gif);
	background-attachment:fixed;
}
.style1 {
	color: #0000FF;
	font-weight: bold;
	font-family: "Comic Sans MS";
	font-size: 36px;
}
.style2 {
	font-family: "Comic Sans MS";
	font-size: 18px;
	color: #009900;
}
.style3 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
<%
Function RandomNumber(intHighestNumber)
	Randomize
	RandomNumber = Int(intHighestNumber * Rnd) + 1
End Function
%>

</head>

<body>
<p align="center" class="style1">Primary Two <br>
Mathematics Multiplication Competition   </p>
<p class="style2">Welcome 
  <b>
  <%
		dim rndnumber
		Response.Write(rndnumber)
		dim sname,studentid
		'yname=Request.Form("yname")
		sname=session("studentname")
		studentid=session("studentid")
		If sname<>"" Then
		      Response.Write(sname)
		End If
%>
		  </b>
		  from 
		  <b>
 <%
		dim sclass
		sclass=session("class")
		If sclass<>"" Then
		      Response.Write(sclass)
		End If
		
%>
<%
		dim tempsql
		tempsql="Select ans from StudRecords where StudentID='" & studentid &"'"
		set rscompleted=Server.CreateObject("ADODB.Recordset")
		rscompleted.Open tempsql,MyConn,3,1
		if rscompleted.EOF=False then
		  dim tempstr,questionids
		  dim i
		  tempstr=rscompleted("ans")
		  questionids=split(tempstr,",")
		  'IF the student completed all the question then give them the
		  'message that you have completed
		  if ubound(questionids)=49 then 
		    Response.Write("<br><br><br><br>")
		    Response.Write("<table align='center'><tr><td>")
		    Response.Write("You have Already Completed")
		    Response.Write("</td></tr></table>")
			Response.End 
		  end if
		 dim isvalid
		 'Get the stduent answers from the table
		 set rsresults=Server.CreateObject("ADODB.Recordset")
		 dim nqry,answeredquestions,icount
		 nqry="Select ans from StudRecords where studentname='" & sname & "'"
		 rsresults.Open nqry,MyConn,3,1
		 'Response.Write("Eof " & rsresults.EOF)
		 if rsresults.EOF=false then
			Response.Write("Records" & rsresults("ans"))
			answeredquestions=split(rsresults("ans"),",")
			'Loop through the returned answers and check whether the the
			'Question is answered or not
		
		 isvalid=false
		 rndnumber=RandomNumber(50)
		' Response.Write("number" & rndnumber)	 
     	 do while isvalid=true
     	 rndnumber=RandomNumber(50)
     	   for icount=lbound(answeredquestions) to ubound(answeredquestions)
			if cint(rndnumber)=cint(answeredquestions(icount)) then
				isvalid=true
			else
				isvalid=false
			end if				
			
			next
		 loop
		 End if
		 
%>
			<TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
	<TR>
		<TD colspan=2>Question</TD>
	</TR>
	<TR>
		<TD>What is Answer for </TD>
	</TR>
	<TR>
		<TD align="center" ><INPUT type="submit" value="Submit" id=submit1 name=submit1></TD>
		<TD align="Center" ><INPUT type="reset" value="Reset" id=reset1 name=reset1></TD>
	</TR>
</TABLE>

			
<%		  
		End if
%>
</b>.</p>
<p>&nbsp;</p>
<p class="style3">Question 1</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="200" border="0" align="center">
  <tr>
    <td width="54" height="28"><form name="form1" method="post" action="index.asp">
  <input type="submit" name="Submit" value="Cancel">
</form></td>
    <td width="106"><form name="form2" method="post" action="">
  <input type="reset" name="Reset" value="Reset Answers">
</form></td>
    <td width="18"><form name="form3" method="post" action="end.asp">
  <input name="Submit" type="submit" value="Submit">
</form></td>
  </tr>
</table>
</body>
</html>