Show region not showing

Discussion in 'ASP General' started by David Ehmer, Nov 16, 2003.

  1. David Ehmer

    David Ehmer Guest

    The code below is 2 rows in a table, the top row contains a message to be
    shown if the recordset returns no matches. The 2nd row will display any
    matches.

    Problem is that if no matches are found nothing is displayed in this table.
    I have used the code that DMX generates using the server behaviour 'Show
    region if recordset is empty', but no success.

    Appreciate someone pointing out where I'm going wrong here.

    Thanks
    David

    <table>
    <tr>
    <td>
    <% If rsOrg.EOF Or rsOrg.BOF Then >
    Sorry, no records were found to match your search.
    <% End If ' end rsOrg.EOF And rsOrg.BOF %</td>
    </tr>
    <tr>
    <td>
    <% If Not rsOrg.EOF Or Not rsOrg.BOF Then %>
    <a
    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    ).Value)%></a>
    <% End If ' end Not rsOrg.EOF Or NOT rsOrg.BOF %>
    </td>
    </tr>
    </table>

    http://www.boatingdirectory.com.au/aust_index.asp
    David Ehmer, Nov 16, 2003
    #1
    1. Advertising

  2. David Ehmer

    Ray at Guest

    Try dropping the .BOF stuff and also make sure that your ASP tags are closed
    properly. (I'll assume that the ones below that aren't closed properly is
    because you didn't actually copy your code.) Also, instead of having two
    separate ifs, try an if/else. One of the conditions will always be true
    then.


    <table>
    <tr>
    <td>
    <% If rsOrg.EOF Then %>
    Sorry, no records were found to match your search.
    <% Else %>
    <a
    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    ).Value)%></a>
    <% End If %>
    </td>
    </tr>
    </table>

    Your best bet is to drop DMX for writing your code. It'll make things a
    little harder to do at first, but you'll benefit much more in the future.

    Ray at home


    "David Ehmer" <> wrote in message
    news:3fb6d895$0$14054$...
    > The code below is 2 rows in a table, the top row contains a message to be
    > shown if the recordset returns no matches. The 2nd row will display any
    > matches.
    >
    > Problem is that if no matches are found nothing is displayed in this

    table.
    > I have used the code that DMX generates using the server behaviour 'Show
    > region if recordset is empty', but no success.
    >
    > Appreciate someone pointing out where I'm going wrong here.
    >
    > Thanks
    > David
    >
    > <table>
    > <tr>
    > <td>
    > <% If rsOrg.EOF Or rsOrg.BOF Then >
    > Sorry, no records were found to match your search.
    > <% End If ' end rsOrg.EOF And rsOrg.BOF %</td>
    > </tr>
    > <tr>
    > <td>
    > <% If Not rsOrg.EOF Or Not rsOrg.BOF Then %>
    > <a
    >

    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    > ).Value)%></a>
    > <% End If ' end Not rsOrg.EOF Or NOT rsOrg.BOF %>
    > </td>
    > </tr>
    > </table>
    >
    > http://www.boatingdirectory.com.au/aust_index.asp
    >
    >
    Ray at, Nov 16, 2003
    #2
    1. Advertising

  3. David Ehmer

    David Ehmer Guest

    Thanks Ray

    Good suggestions, which I've implemented but it hasn't changed the result.
    Seems illogical that it doesn't display the no matches text. I guess I'm
    missing something obvious.

    David
    "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
    news:OdPL$F$...
    > Try dropping the .BOF stuff and also make sure that your ASP tags are

    closed
    > properly. (I'll assume that the ones below that aren't closed properly is
    > because you didn't actually copy your code.) Also, instead of having two
    > separate ifs, try an if/else. One of the conditions will always be true
    > then.
    >
    >
    > <table>
    > <tr>
    > <td>
    > <% If rsOrg.EOF Then %>
    > Sorry, no records were found to match your search.
    > <% Else %>
    > <a
    >

    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    > ).Value)%></a>
    > <% End If %>
    > </td>
    > </tr>
    > </table>
    >
    > Your best bet is to drop DMX for writing your code. It'll make things a
    > little harder to do at first, but you'll benefit much more in the future.
    >
    > Ray at home
    >
    >
    > "David Ehmer" <> wrote in message
    > news:3fb6d895$0$14054$...
    > > The code below is 2 rows in a table, the top row contains a message to

    be
    > > shown if the recordset returns no matches. The 2nd row will display any
    > > matches.
    > >
    > > Problem is that if no matches are found nothing is displayed in this

    > table.
    > > I have used the code that DMX generates using the server behaviour 'Show
    > > region if recordset is empty', but no success.
    > >
    > > Appreciate someone pointing out where I'm going wrong here.
    > >
    > > Thanks
    > > David
    > >
    > > <table>
    > > <tr>
    > > <td>
    > > <% If rsOrg.EOF Or rsOrg.BOF Then >
    > > Sorry, no records were found to match your search.
    > > <% End If ' end rsOrg.EOF And rsOrg.BOF %</td>
    > > </tr>
    > > <tr>
    > > <td>
    > > <% If Not rsOrg.EOF Or Not rsOrg.BOF Then %>
    > > <a
    > >

    >

    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    > > ).Value)%></a>
    > > <% End If ' end Not rsOrg.EOF Or NOT rsOrg.BOF %>
    > > </td>
    > > </tr>
    > > </table>
    > >
    > > http://www.boatingdirectory.com.au/aust_index.asp
    > >
    > >

    >
    >
    David Ehmer, Nov 16, 2003
    #3
  4. David Ehmer

    Bob Barrows Guest

    David Ehmer wrote:
    > The code below is 2 rows in a table, the top row contains a message
    > to be shown if the recordset returns no matches. The 2nd row will
    > display any matches.
    >
    > Problem is that if no matches are found nothing is displayed in this
    > table. I have used the code that DMX generates using the server
    > behaviour 'Show region if recordset is empty', but no success.
    >
    > Appreciate someone pointing out where I'm going wrong here.
    >
    > Thanks
    > David
    >


    I am assuming you have a scrollable cursor, and that some recordset
    navigation has taken place before this block of code, explaining the need to
    test both EOF and BOF.

    > <% If rsOrg.EOF Or rsOrg.BOF Then >


    The "Or" should be "And" here. Your recordset contains no records only if
    BOTH EOF and BOF are true, so you need to use "And". If some previous code
    in this page had looped through the recordset so that it was at EOF, then
    you would get the "no records" message when there actually were records.

    > Sorry, no records were found to match your search.
    > <% End If ' end rsOrg.EOF And rsOrg.BOF %</td>
    > </tr>
    > <tr>
    > <td>
    > <% If Not rsOrg.EOF Or Not rsOrg.BOF Then %>


    This If statement will allow the following line of code to run if either EOF
    or BOF is true, which will raise an error.
    With that in mind, let's analyze this statement:

    Assume that the previous code had looped through the recordset until the
    recordset was at EOF (EOF = true). The first boolean expression, Not
    rsOrg.EOF, will evaluate to False. So far so good.
    However, the second expression, Not rsOrg.BOF, will evaluate to True! Not
    good, because the Or operator has been used, causing the entire espression
    to evaluate to True (Or causes the expression to be True if at least one of
    the sub-expressions is True). So the following statement will be executed,
    and an error will be raised when the field values are attempted to be read.

    A better way to write to write this statement would be

    If Not (rsOrg.EOF Or rsOrg.BOF) Then

    Now if either EOF or BOF is true, the expression in the parentheses will
    evaluate to True. The Not will change the result to False, and the following
    code will not run. Conversely, if neither EOF and BOF is true, then the
    parenthetical expression will evaluate to False, and the Not will change it
    to True, allowing the following code to run.

    However, I do not believe we have found your problem yet. How are you
    verifying that the recordset actually contains records?

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows, Nov 16, 2003
    #4
  5. David Ehmer

    Ray at Guest

    There must be an HTML issue (have you viewed source) or something else that
    is preventing the whole block of code from running. Is that code all in an
    IF block as well? If so, look at that condition. Or take this code out and
    put it in its own page by itself to see what happens.

    Ray at home

    "David Ehmer" <> wrote in message
    news:3fb76a70$0$13673$...
    > Thanks Ray
    >
    > Good suggestions, which I've implemented but it hasn't changed the result.
    > Seems illogical that it doesn't display the no matches text. I guess I'm
    > missing something obvious.
    >
    > David
    > "Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
    > news:OdPL$F$...
    > > Try dropping the .BOF stuff and also make sure that your ASP tags are

    > closed
    > > properly. (I'll assume that the ones below that aren't closed properly

    is
    > > because you didn't actually copy your code.) Also, instead of having

    two
    > > separate ifs, try an if/else. One of the conditions will always be true
    > > then.
    > >
    > >
    > > <table>
    > > <tr>
    > > <td>
    > > <% If rsOrg.EOF Then %>
    > > Sorry, no records were found to match your search.
    > > <% Else %>
    > > <a
    > >

    >

    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    > > ).Value)%></a>
    > > <% End If %>
    > > </td>
    > > </tr>
    > > </table>
    > >
    > > Your best bet is to drop DMX for writing your code. It'll make things a
    > > little harder to do at first, but you'll benefit much more in the

    future.
    > >
    > > Ray at home
    > >
    > >
    > > "David Ehmer" <> wrote in message
    > > news:3fb6d895$0$14054$...
    > > > The code below is 2 rows in a table, the top row contains a message to

    > be
    > > > shown if the recordset returns no matches. The 2nd row will display

    any
    > > > matches.
    > > >
    > > > Problem is that if no matches are found nothing is displayed in this

    > > table.
    > > > I have used the code that DMX generates using the server behaviour

    'Show
    > > > region if recordset is empty', but no success.
    > > >
    > > > Appreciate someone pointing out where I'm going wrong here.
    > > >
    > > > Thanks
    > > > David
    > > >
    > > > <table>
    > > > <tr>
    > > > <td>
    > > > <% If rsOrg.EOF Or rsOrg.BOF Then >
    > > > Sorry, no records were found to match your search.
    > > > <% End If ' end rsOrg.EOF And rsOrg.BOF %</td>
    > > > </tr>
    > > > <tr>
    > > > <td>
    > > > <% If Not rsOrg.EOF Or Not rsOrg.BOF Then %>
    > > > <a
    > > >

    > >

    >

    href="<%=(rsOrg.Fields.Item("Web").Value)%>"><%=(rsOrg.Fields.Item("OrgName"
    > > > ).Value)%></a>
    > > > <% End If ' end Not rsOrg.EOF Or NOT rsOrg.BOF %>
    > > > </td>
    > > > </tr>
    > > > </table>
    > > >
    > > > http://www.boatingdirectory.com.au/aust_index.asp
    > > >
    > > >

    > >
    > >

    >
    >
    Ray at, Nov 16, 2003
    #5
  6. David Ehmer

    David Ehmer Guest

    Thanks for the suggestions.

    I tried applying the show/if code block to the whole table to display
    records and using an else structure to display a 2nd table with the 'no
    matches' text. Worked ok then.

    David
    "Bob Barrows" <> wrote in message
    news:...
    > David Ehmer wrote:
    > > The code below is 2 rows in a table, the top row contains a message
    > > to be shown if the recordset returns no matches. The 2nd row will
    > > display any matches.
    > >
    > > Problem is that if no matches are found nothing is displayed in this
    > > table. I have used the code that DMX generates using the server
    > > behaviour 'Show region if recordset is empty', but no success.
    > >
    > > Appreciate someone pointing out where I'm going wrong here.
    > >
    > > Thanks
    > > David
    > >

    >
    > I am assuming you have a scrollable cursor, and that some recordset
    > navigation has taken place before this block of code, explaining the need

    to
    > test both EOF and BOF.
    >
    > > <% If rsOrg.EOF Or rsOrg.BOF Then >

    >
    > The "Or" should be "And" here. Your recordset contains no records only if
    > BOTH EOF and BOF are true, so you need to use "And". If some previous code
    > in this page had looped through the recordset so that it was at EOF, then
    > you would get the "no records" message when there actually were records.
    >
    > > Sorry, no records were found to match your search.
    > > <% End If ' end rsOrg.EOF And rsOrg.BOF %</td>
    > > </tr>
    > > <tr>
    > > <td>
    > > <% If Not rsOrg.EOF Or Not rsOrg.BOF Then %>

    >
    > This If statement will allow the following line of code to run if either

    EOF
    > or BOF is true, which will raise an error.
    > With that in mind, let's analyze this statement:
    >
    > Assume that the previous code had looped through the recordset until the
    > recordset was at EOF (EOF = true). The first boolean expression, Not
    > rsOrg.EOF, will evaluate to False. So far so good.
    > However, the second expression, Not rsOrg.BOF, will evaluate to True! Not
    > good, because the Or operator has been used, causing the entire espression
    > to evaluate to True (Or causes the expression to be True if at least one

    of
    > the sub-expressions is True). So the following statement will be executed,
    > and an error will be raised when the field values are attempted to be

    read.
    >
    > A better way to write to write this statement would be
    >
    > If Not (rsOrg.EOF Or rsOrg.BOF) Then
    >
    > Now if either EOF or BOF is true, the expression in the parentheses will
    > evaluate to True. The Not will change the result to False, and the

    following
    > code will not run. Conversely, if neither EOF and BOF is true, then the
    > parenthetical expression will evaluate to False, and the Not will change

    it
    > to True, allowing the following code to run.
    >
    > However, I do not believe we have found your problem yet. How are you
    > verifying that the recordset actually contains records?
    >
    > Bob Barrows
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
    David Ehmer, Nov 17, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt

    TO show or NOT to show

    Matt, May 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    379
  2. Steve Lewis - Website Nation

    Condtional Region or Show/Hide Section

    Steve Lewis - Website Nation, Aug 12, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    5,013
    Steve Lewis - Website Nation
    Aug 13, 2005
  3. Ray Booysen
    Replies:
    2
    Views:
    644
    Ray Booysen
    Mar 28, 2006
  4. defn noob
    Replies:
    3
    Views:
    392
    ssecorp
    Jul 3, 2008
  5. SAL

    #Region #End Region issue

    SAL, Aug 29, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    355
    Alexey Smirnov
    Aug 29, 2008
Loading...

Share This Page