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!

Hello, I am experiencing a problem

Status
Not open for further replies.

TJunior

IS-IT--Management
Jan 18, 2002
33
0
0
DE
Hello, I am experiencing a problem when using an if statement. What I am trying to do is retrieve information from my database. It' works when there are records in the database that match the conditions of the SQL query. However if there are no results found I get a IIS generated error page, when what I really want is my own specified error page to be displayed. The code I am using is as follows:

If Not (objRS.eof And objRS.bof) Then
Response.Write (&quot;<table Align=&quot;&quot;center&quot;&quot; border=&quot;&quot;0&quot;&quot;>&quot;)
Response.Write (&quot;<tr>&quot;)
Response.Write (&quot;<td width=&quot;&quot;200&quot;&quot;>&quot; & objRS(&quot;EquipDescript&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;150&quot;&quot;>&quot; & objRS(&quot;ContractNo&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;300&quot;&quot;>&quot; & objRS(&quot;Location&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;100&quot;&quot;><a href=&quot;&quot;EquipmentCfg.asp&quot;&quot;>View Config</a></td>&quot;)
Response.Write (&quot;</tr>&quot;)
Response.Write (&quot;</table>&quot;)
objRS.MoveNext

Else

Response.Redirect (&quot;PartsError.asp&quot;)
End if


The error I get is :


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


Can you please help me to find where I am going wrong. Thank you.
 
you have a rs.movenext: where is your loop?
If you don't have a loop than the error is on rs.movenext line if the recordset contains only one record
 
I tested the code and it works like it is supposed to. The problem may be in the code above the block you posted.
Can you post the rest of the code?
 
This is the code with the loop included:

While Not objRS.EOF

If Not (objRS.eof And objRS.bof) Then
Response.Write (&quot;<table Align=&quot;&quot;center&quot;&quot; border=&quot;&quot;0&quot;&quot;>&quot;)
Response.Write (&quot;<tr>&quot;)
Response.Write (&quot;<td width=&quot;&quot;200&quot;&quot;>&quot; & objRS(&quot;EquipDescript&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;150&quot;&quot;>&quot; & objRS(&quot;ContractNo&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;300&quot;&quot;>&quot; & objRS(&quot;Location&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;100&quot;&quot;><a href=&quot;&quot;EquipmentCfg.asp&quot;&quot;>View Config</a></td>&quot;)
Response.Write (&quot;</tr>&quot;)
Response.Write (&quot;</table>&quot;)
objRS.MoveNext

Else

Response.Redirect (&quot;PartsError.asp&quot;)
End if

wend


And here is the SQL statement:

strQ = &quot;SELECT tbl_EquipCfg.*, EquipDescript, ContractNo, Location, CompanyName &quot;
strQ = strQ & &quot;FROM tbl_EquipCfg, tbl_Contracts, tbl_CustomerLocations, tbl_Equipment, tble_Customers &quot;
strQ = strQ & &quot;WHERE tble_Customers.recid = '&quot; & request.cookies(&quot;passes2&quot;) & &quot;' &quot;
strQ = strQ & &quot;AND tbl_Contracts.CustomerId = tble_Customers.recid &quot;
strQ = strQ & &quot;AND tbl_EquipCfg.ContractId = tbl_Contracts.recid &quot;
strQ = strQ & &quot;AND tbl_EquipCfg.EquipId = tbl_Equipment.recid &quot;
strQ = strQ & &quot;AND tbl_EquipCfg.LocationId = tbl_CustomerLocations.recid &quot;
objRS.Open strQ

Maybe it's the way I am querying the database???
 
Do you have any other line in the page where you call objRs?
If not your code should work. Try also this (but its the same only the condition different)

If Not (objRS.eof And objRS.bof) Then
While Not objRS.EOF
Response.Write (&quot;<table Align=&quot;&quot;center&quot;&quot; border=&quot;&quot;0&quot;&quot;>&quot;)
Response.Write (&quot;<tr>&quot;)
Response.Write (&quot;<td width=&quot;&quot;200&quot;&quot;>&quot; & objRS(&quot;EquipDescript&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;150&quot;&quot;>&quot; & objRS(&quot;ContractNo&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;300&quot;&quot;>&quot; & objRS(&quot;Location&quot;) & &quot;</td>&quot;)
Response.Write (&quot;<td width=&quot;&quot;100&quot;&quot;><a href=&quot;&quot;EquipmentCfg.asp&quot;&quot;>View Config</a></td>&quot;)
Response.Write (&quot;</tr>&quot;)
Response.Write (&quot;</table>&quot;)
objRS.MoveNext
wend
Else
Response.Redirect (&quot;PartsError.asp&quot;)
End if

 
Thanks, that change has seemed to solve the problem. Thanks again.

I know I should create a new thread but seen as you have a slight idea of my code I though I might ask you another question...I am attempting to differenciat between different sites of one perticulat company e.g. Comany X has three sites - siteA, siteB, and siteC.

I would like to be able to look at information at each of the sites seperately. I know it's to do with the database structure, but I thought I'd ask if you had any pointers.

Thank you for you time.
 
What do you mean by that:
&quot;I would like to be able to look at information at each of the sites seperately. &quot;
Can you explain more in detail?
 
Okay I have a database which stores information of clients and the equipment they have at their sites. Some clients have several sites.

Scenario
So lets say client X has 3 sites. And at each site he has 10 pieces of equipment.
What I want to be able to do is get at the information for the client with a description of each site and the equipment at that site.

e.g.

Client X

SiteA has equip1, equp2...equip10 or 3 0f equip1, 4 Of equip2
SiteB has equip1, equp2...equip10
SiteC has equip1, equp2...equip10

Does this make it any clearer?
 
yes. can you send the tables structure and I will try so write the sql statement for you.
You will have a recordset on the page which you will have to parse and put some condition to formate it properly

Durug
 
What's your mail address so I can send you the table layout, because I can't of any way to attach it to a thread. And writing it all down will take forever, although if that is the only way then I have no choice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top