?
Solved

If statement error

Posted on 2005-03-19
5
Medium Priority
?
289 Views
Last Modified: 2008-02-26
I get an error with an if statement calling from a sql database-

sType - is the column header.    Residential - is in a cell in the column.

I want to put a table row in a webpage only if 'Residential' is in the cell. When I run the below code it gives me an error, any reason why?:

error '80020009'

/searchResults3.asp, line 194

CODE:

<% if rsPage("sType") = "Residential" then %>                                                                  
                                              <tr align="center" valign="middle" bgcolor="Silver" class="small">
                                                <td width="17%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;PHOTO&nbsp;</b></div></td>
                                                <td width="7%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;AREA&nbsp;</b></div></td>
                                                <td width="25%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;ADDRESS&nbsp;</b></div></td>
                                                <td width="4%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;BR&nbsp;</b></div></td>
                                                <td width="4%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;BA&nbsp;</b></div></td>
                                                <td width="11%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;SQFT&nbsp;</b></div></td>
                                                <td width="15%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;MLS
                                                    NUMBER&nbsp;</b></div></td>
                                                <td width="17%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;PRICE&nbsp;</b></div></td>
                                              </tr>
<% end if %>
0
Comment
Question by:javajamminman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
paelo earned 2000 total points
ID: 13583938
If I'm not mistaken, error '80020009' is EOF/BOF (end of file/beginning of file).  That means the problem is probably beforehand, where you open the recordset and navigate to the record.  Can you post that code?  Can you check the resultset to see how many results are received?

-Paul.
0
 

Author Comment

by:javajamminman
ID: 13583980
Paul,

If I take out the IF and END IF, I get no error. The table row shows up.  I also placed <%=rsPage("sTYPE")%> in the .asp page and the word - Residential - showed up, so the database is being called and the cell content displays properly.

Now, I tried the following -

Dim Residential

<%
Residential = rsPage("sTYPE")                                                                  
if rsPage("sTYPE") = Residential then
%>
                                              <tr align="center" valign="middle" bgcolor="Silver" class="small">
                                                <td width="17%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;PHOTO&nbsp;</b></div></td>
                                                <td width="7%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;AREA&nbsp;</b></div></td>
                                                <td width="25%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;ADDRESS&nbsp;</b></div></td>
                                                <td width="4%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;BR&nbsp;</b></div></td>
                                                <td width="4%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;BA&nbsp;</b></div></td>
                                                <td width="11%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;SQFT&nbsp;</b></div></td>
                                                <td width="15%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;MLS
                                                    NUMBER&nbsp;</b></div></td>
                                                <td width="17%" nowrap class="small">
                                                  <div align="center"><b>&nbsp;PRICE&nbsp;</b></div></td>
                                              </tr>
<% end if %>

But now get the following error -

<% end if %>ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
0
 

Author Comment

by:javajamminman
ID: 13583997
Below is pertinent code before it:

' Build our SQL String using the parameters we just got.
strSQL  = "SELECT * FROM Prop_Prod WHERE 1 = 1 AND TOUR_NU=('" & Request("TOUR_NU") & "') OR CUST_ID=('" & Request("CUST_ID") & "') "
If Len(Session("TOUR_NU")) > 0 Then strSQL = strSQL & "AND (TOUR_NU = '" & Session("TOUR_NU") & "' ) "
If Len(Session("sTYPE")) > 0 Then strSQL = strSQL & "AND (sTYPE = '" & Session("sTYPE") & "' ) "
If Len(Session("CONTACT01")) > 0 Then strSQL = strSQL & "AND (CONTACT01 = '" & Session("CONTACT01") & "' ) "
If Len(Session("CUST_ID")) > 0 Then strSQL = strSQL & "AND (CUST_ID = '" & Session("CUST_ID") & "' ) "
If Len(Session("MLS")) > 0 Then strSQL = strSQL & "AND (MLS = '" & Session("MLS") & "' ) "
If Len(Session("ST_NAME")) > 0 Then strSQL = strSQL & "AND (ST_NAME = '" & Session("ST_NAME") & "' ) "
If Len(Session("LIST_TYPE")) > 0 Then strSQL = strSQL & "AND (LIST_TYPE = '" & Session("LIST_TYPE") & "' ) "
If Len(Session("BR")) > 0 Then strSQL = strSQL & "AND (BR >= '" & Session("BR") & "' ) "
If Len(Session("BA")) > 0 Then strSQL = strSQL & "AND (BA >= '" & Session("BA") & "' )  "
If Len(Session("SQFT")) > 0 Then strSQL = strSQL & "AND (SQFT >= '" & Session("SQFT") & "' ) "
If Len(Session("LPRICE")) > 0 Then strSQL = strSQL & "AND (PRICE >= '" & Session("LPRICE") & "' ) "
If Len(Session("HPRICE")) > 0 Then strSQL = strSQL & "AND (PRICE <= '" & Session("HPRICE") & "' ) " 
'if Len(Request("SortBy")) > 0 then
'   strSQL = strSQL & "ORDER BY ('" & Request("SortBy") & "') "
'   else
'   strSQL = strSQL & tmpSortBy
'end if
'strSQL = strSQL & "ORDER BY ('" & Request("SortBy") & "') ; "
'strSortBy = Request.QueryString("sortby")
'******strSQL = strSQL & "Order By PRICE desc "

' Some lines I used while writing to debug... uh "test", yeah that's it!
' Left them FYI.
'strSQL = "SELECT * FROM sample WHERE id=1234 ORDER BY id;"
'strSQL = "SELECT * FROM sample;"
'Response.Write "SQL Query: " &  strSQL & "<BR>" & vbCrLf

 con.Open "driver={SQL Server};server=sqla33.webcenter.com;port=5000;uid=blank;pwd=blank;database=blank;"

   'Need a rich cursor type to support paging
   rsPage.CursorType = 3 'adOpenStatic

     'Open recordset                    
   rsPage.Open strSQL, Con

' Get the count of the pages using the given page size
iPageCount = rsPage.PageCount
%>
                                                </TD>
                                                <TD width="13%"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font>
                                                <TD> <div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>
                                                    <b>- RETURNED RECORDS -&nbsp;&nbsp;&nbsp;</b>[&nbsp;<a href="Search.asp">New
                                                    Search</a>&nbsp;]</strong></font></div></TR>
                                            </TABLE>
                                            <table border="0" cellpadding="2" cellspacing="2" width="100%">
0
 

Author Comment

by:javajamminman
ID: 13584033
Paul,

I'm assigning you the points. You asked about the result set count and it occured to me I was searching on a blank form which is why it was coming up empty. I just now have to add the elseif to assign a blank row.

Thanks Paul for aiming me to a dumb mistake I was making. But then again, I've never created IF statements before.
0
 
LVL 9

Expert Comment

by:paelo
ID: 13584099
Thanks for the points.  Sorry I wasn't able to follow up quicker, I got distracted by something else.

-Paul.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question