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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query accross two tables determins the write comand, help

Status
Not open for further replies.

wizzzard

Programmer
May 28, 2001
1
GB
Hi, I am having major problems when the with a reletivly simple peice of code, I have two tables one for questions and another for the answers which will be multiple choice , therefore each question will have 2 or more answers, so to test this I am trying to print out the question with the relevant set of answers in a table. The problem I am having is testing the answer with the question, the relation is where they both have the same question ID.....

Here is the error message:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.

I have tested different ways,the problem is in this line:
oRSQuestions("quest_id").value = oRSanswers("quest_id").value


Please can someone look at my code to see if they know where I am going wrong, i would really appreciate any suggestions.

<%
set oRSanswers = Server.CreateObject(&quot;ADODB.Recordset&quot;)
oRSanswers.ActiveConnection = &quot;driver={SQL Server)**&quot;
oRSanswers.CursorType = 1
oRSanswers.CursorLocation = 1
oRSanswers.LockType = 1
oRSanswers_numRows = 0
set oRSQuestions = Server.CreateObject(&quot;ADODB.Recordset&quot;)
oRSQuestions.ActiveConnection = &quot;driver={SQL Server}**&quot;
oRSQuestions.CursorType = 1
oRSQuestions.CursorLocation = 1
oRSQuestions.LockType = 1
oRSQuestions_numRows = 0
oRSQuestions.source = &quot;SELECT question FROM QUESTIONS ORDER BY QUEST_ID&quot;
oRSanswers.source = &quot;SELECT answer FROM ANSWERS ORDER BY QUEST_ID&quot;
oRSQuestions.Open
oRSanswers.Open

do while not oRSQuestions.EOF
response.write&quot;<tr>&quot;
response.write&quot;<td>&quot;& oRSQuestions(&quot;question&quot;) &&quot;</td>&quot;

do while NOT oRSanswers.EOF AND oRSQuestions(&quot;quest_id&quot;).value = oRSanswers(&quot;quest_id&quot;).value

response.write&quot;<td>&quot;& oRSanswers(&quot;answer&quot;)&&quot;</td>&quot;

oRSanswers.movenext

loop
response.write&quot;</TR>&quot;
oRSQuestions.movenext
loop

oRSanswers.close
oRSQuestions.close
set oRSanswers = nothing
set oRSQuestions = nothing

%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top