Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

If statement error

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
javajamminman
Asked:
javajamminman
  • 3
  • 2
1 Solution
 
paeloCommented:
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
 
javajamminmanAuthor Commented:
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
 
javajamminmanAuthor Commented:
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
 
javajamminmanAuthor Commented:
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
 
paeloCommented:
Thanks for the points.  Sorry I wasn't able to follow up quicker, I got distracted by something else.

-Paul.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now