Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2004, 08:14 PM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Possible Emty Record Set

I have a drop down list that contains a list of agencies and another drop down list that contains names. In one table is a list of names and in anohter table is a list of agencies. In a third table there are many field including a value for agency and a value for names, which the user has selected or will select. names is known as interviewd by. When a user would like to lookup a specifict record he or she types the number in to an input box and the records does display on a form. If the Interviewed colum does not have anything in it then the drop down box that apears next to interviewed by will begin with a blank line. When the user clicks on the drop down arrow and the user can select a name from the list which comes from the interviewed by table. The same thing happens for the agency field. Everything works well when I just run the code for the Interviewd by feild but when I add the code for the agecy feild I get an error. I only get an error if I am supposed to start with a value in the agency drop down box. If I am not supposed to start with a value in the agency drop down box everything works. Below please find the error and the code for agency and Interviewed By. I ran the qiery for agency in access and it works.

Error:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/start5.asp

Code

<%'this is for agency %>
<td>agency
<% set rec=Server.CreateObject("ADODB.recordset") %>
<% strsql3 = "select Agency From TBLagency order by Agency;" %>
<% rec.Open strsql3, conn %>
agency
<% rec.movefirst %>
<% rs.movefirst %>
<% rs.movefirst %>
<% agency2 = rs("agency") %>
<SELECt NAME = "agency2">
<option value="<%=rs("agency")%>"> <%=rs("agency")%></option>
<% do until rec.eof %>
    <% if rec("agency") = agency2 then %>
        <% rec.movenext %>
        <option value="<%=rec("agency")%>"> <%=rec("agency")%></option>
        <% rec.movenext %>
<% else %>
        <option value="<%=rec("agency")%>"> <%=rec("agency")%></option>
        <% rec.movenext %>
    <% end if %>
<% loop %>
</select></td>
<% 'end of agency%>


</tr>
<tr>
<% 'create a connection to tblfinal_table and TBLinterview
set rs=Server.CreateObject("ADODB.recordset")
set rs2=Server.CreateObject("ADODB.recordset")

rs.Open strsql, conn
rs2.Open strsql2, conn
%>

<%'this is for interviewed by %>
<td>Interviewed By
<% rs2.movefirst %>
<% rs.movefirst %>
<% rs.movefirst %>
<% Interviewee = rs("Interviewed By") %>
<SELECt NAME = "interview">
<option value="<%=rs("Interviewed By")%>"> <%=rs("Interviewed By")%></option>
<% do until rs2.eof %>
    <% if rs2("interviewed BY") = interviewee then %>
        <% rs2.movenext %>
        <option value="<%=rs2("Interviewed By")%>"> <%=rs2("Interviewed By")%></option>
        <% rs2.movenext %>
<% else %>
        <option value="<%=rs2("Interviewed By")%>"> <%=rs2("Interviewed By")%></option>
        <% rs2.movenext %>
    <% end if %>
<% loop %>
</select></td>
<% 'end of interview %>

Thank you very much for your help in advance
Andrew Englander



 
Old November 24th, 2004, 12:31 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

If there are no records in database and you use the following:
<% rs.movefirst %>
then you will get the error.
check for rs.EOF and then proceed.

Om Prakash
 
Old November 24th, 2004, 01:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Andrew,
Quote:
quote:<% set rec=Server.CreateObject("ADODB.recordset") %>
<% strsql3 = "select Agency From TBLagency order by Agency;" %>
<% rec.Open strsql3, conn %>
agency
<% rec.movefirst %>
<% rs.movefirst %>
<% rs.movefirst %>
I don't understand why you have to use rs.movefirst there in the above code. I don't see it being initialized. What does "rs" contain? And why is that you are using it twice? Similarly in the NAMEs list code.

It is always better to check if the recordset contains something in it once it has been populated with execution of a query. Only if that contains some resultset, you should process further.
For example:
Code:
<% set rec=Server.CreateObject("ADODB.recordset") strsql3 = "select Agency From TBLagency order by Agency;" %>
rec.Open strsql3, conn
If NOT rec.EOF then
    While not rec.EOF
        '... Code to display the resultset formatted.
        rec.MoveNext
    Wend
Else
    '... REC DOESNT CONTAIN ANYTHING IN IT
End If%>
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
help about record set shankhan Classic ASP Databases 1 June 5th, 2005 10:51 PM
Inserting A Record Set nikotromus Access VBA 3 September 14th, 2004 01:23 PM
dynamicly name a record set mat41 Classic ASP Professional 6 March 16th, 2004 03:50 AM
ADO Record Set Question virtualdave Pro VB Databases 4 February 20th, 2004 12:21 PM
record set problem spraveens Classic ASP Databases 6 September 12th, 2003 06:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.