recordset while loop problem

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default recordset while loop problem

    Hi all,

    I'm trying to write a bit of ASP code topopulate a select box, the data that
    I'm using to fill the select box is in a recordset - which also contains
    data for other selectboxes. - hence the 'manufacturer' feild getting
    compared. The code I'm using is this -

    <select name="select" size="1">
    <option value="Select a Model!" selected="selected">Select a
    Model</option>
    <option value="Select a Model">Show All</option>
    <%While ((NOT pullallmanhorizmodels.EOF) AND
    (allsunbedman.Fields.Item("manufacturer").Value =
    pullallmanhorizmodels.Fields.Item("manufacturer"). Value))%>
    <option
    value="<%=pullallmanhorizmodels.Fields.Item("model ")%>"><%=pullallmanhorizmo
    dels.Fields.Item("model")%></option>
    <% pullallmanhorizmodels.MoveNext
    wend%>
    </select>

    It 'seem's' to be working until it gets to the last record, where it causes
    the computer to hang?

    Cheers.


    Dyslexic Guest

  2. Similar Questions and Discussions

    1. PHP Recordset Paging problem
      I am trying to set up record paging using the simple <<Previous Next>> setup. However, when I click the Next>> link, it doesn't show the rest of the...
    2. Recordset paging problem
      I'm stuck on this one My recordset paging wont work. I've done a search page with a form and a table in it to post 2 values to the result page....
    3. Recordset problem
      Hi, here is my situation, in an access database i have a field which has 4 possible values (they are 'none', '1-2', '3-4', '5ormore') i want to...
    4. Recordset Problem with Access
      I have created a log in page, which works and the information is routed to an Access database; I have also created a confirm page which is supposed...
    5. Problem with Recordset from SQL Server
      I have just upsized an Access database to MS SQL and have begun converting and testing ASP pages created in Dreamweaver. After creating a Recordset...
  3. #2

    Default Re: recordset while loop problem

    without really answering to your question,
    why not change your SQL statement usign a JOIN to avoid having to use 2
    recordset, while it's probably possible to get all the data in the format
    you need in a single recordset, and thus simplifying things a lot

    "Dyslexic" <I'hate-@ll&^SPAMH@r^esters.com> wrote in message
    news:4wAfc.14228$Z07.7167@news-binary.blueyonder.co.uk...
    > Hi all,
    >
    > I'm trying to write a bit of ASP code topopulate a select box, the data
    that
    > I'm using to fill the select box is in a recordset - which also contains
    > data for other selectboxes. - hence the 'manufacturer' feild getting
    > compared. The code I'm using is this -
    >
    > <select name="select" size="1">
    > <option value="Select a Model!" selected="selected">Select a
    > Model</option>
    > <option value="Select a Model">Show All</option>
    > <%While ((NOT pullallmanhorizmodels.EOF) AND
    > (allsunbedman.Fields.Item("manufacturer").Value =
    > pullallmanhorizmodels.Fields.Item("manufacturer"). Value))%>
    > <option
    >
    value="<%=pullallmanhorizmodels.Fields.Item("model ")%>"><%=pullallmanhorizmo
    > dels.Fields.Item("model")%></option>
    > <% pullallmanhorizmodels.MoveNext
    > wend%>
    > </select>
    >
    > It 'seem's' to be working until it gets to the last record, where it
    causes
    > the computer to hang?
    >
    > Cheers.
    >
    >

    J. Baute Guest

  4. #3

    Default Re: recordset while loop problem

    Hi Mate,
    Thanks for your response, regarding your suggestion of using a JOIN
    statement to get all this info in the one recordset - As you can see from my
    code I currently have two recordsets, I did this because the first recordset
    is looped round a Horiz/Vertical looper, the second recordset provides the
    options for the selectbox (for each of the items in the first loop) - I did
    try using a JOIN statement but had problems getting the JOIN statement to
    work with my crappy access odbc/db (newbie alert here) - even if I get the
    join statement to work I'll still be left with the problem of selecting the
    correct/relevant items for each selectbox.(the data for many different
    selectbox's is returned within the pullallmanhorizmodels recordset.

    I'm sure I'm doing something silly here - could it possibly be to do with
    comparing the two "manufacturer" fields once it reaches the last record
    (n.b- even with a join statement I would need a condition like this to
    separate the contents for each selkectbox). (As I said before - it works
    fine until it reaches the last "pullallmanhorizmodels" record then just
    seems to hang the web page (I can publish this page if it would provide any
    useful info) there are no error messages or anything the server just stop's
    serving the rest of the page.

    Again - Cheers,

    Dyslexic.


    "J. Baute" <WUPYRDEDAWJD@spammotel.com> wrote in message
    news:407f8374$0$992$a0ced6e1@news.skynet.be...
    > without really answering to your question,
    > why not change your SQL statement usign a JOIN to avoid having to use 2
    > recordset, while it's probably possible to get all the data in the format
    > you need in a single recordset, and thus simplifying things a lot
    >
    > "Dyslexic" <I'hate-@ll&^SPAMH@r^esters.com> wrote in message
    > news:4wAfc.14228$Z07.7167@news-binary.blueyonder.co.uk...
    > > Hi all,
    > >
    > > I'm trying to write a bit of ASP code topopulate a select box, the data
    > that
    > > I'm using to fill the select box is in a recordset - which also
    contains
    > > data for other selectboxes. - hence the 'manufacturer' feild getting
    > > compared. The code I'm using is this -
    > >
    > > <select name="select" size="1">
    > > <option value="Select a Model!" selected="selected">Select a
    > > Model</option>
    > > <option value="Select a Model">Show All</option>
    > > <%While ((NOT pullallmanhorizmodels.EOF) AND
    > > (allsunbedman.Fields.Item("manufacturer").Value =
    > > pullallmanhorizmodels.Fields.Item("manufacturer"). Value))%>
    > > <option
    > >
    >
    value="<%=pullallmanhorizmodels.Fields.Item("model ")%>"><%=pullallmanhorizmo
    > > dels.Fields.Item("model")%></option>
    > > <% pullallmanhorizmodels.MoveNext
    > > wend%>
    > > </select>
    > >
    > > It 'seem's' to be working until it gets to the last record, where it
    > causes
    > > the computer to hang?
    > >
    > > Cheers.
    > >
    > >
    >
    >

    Dyslexic Guest

  5. #4

    Default Re: recordset while loop problem

    "Dyslexic" <qwert@@@@.com>
    > I'm sure I'm doing something silly here - could it possibly be to do with
    > comparing the two "manufacturer" fields once it reaches the last record
    Probably, but if that is the case I'm surprised that you don't get an error.

    Does this work ---

    do until pullallmanhorizmodels.EOF

    if pullallmanhorizmodels("manufacturer") = allsunbedman("manufacturer")
    then
    %><option value= ---etc--- </option><%
    end if

    pullallmanhorizmodels.MoveNext

    loop


    --
    roger


    roger Guest

  6. #5

    Default Re: recordset while loop problem


    "roger" <mothland@btopenworld.com> wrote in message
    news:c5pm5m$f2k$1@hercules.btinternet.com...
    > "Dyslexic" <qwert@@@@.com>
    >
    > > I'm sure I'm doing something silly here - could it possibly be to do
    with
    > > comparing the two "manufacturer" fields once it reaches the last record
    >
    > Probably, but if that is the case I'm surprised that you don't get an
    error.
    >
    > Does this work ---
    >
    > do until pullallmanhorizmodels.EOF
    >
    > if pullallmanhorizmodels("manufacturer") =
    allsunbedman("manufacturer")
    > then
    > %><option value= ---etc--- </option><%
    > end if
    >
    > pullallmanhorizmodels.MoveNext
    >
    > loop
    END SNIP

    Hi Rodger,

    Thanks for you help, I've tried many different ways to get the same logic as
    what my original 'should' do but am failing horribly. I have tried and got
    working your code (I used a 'while' outer loop, instead of your 'do until'
    loop but it was essentially the same).

    This code works perfectly within its own rights but does not give my desired
    results because the 'do until' loop takes the 'pullallmanhorizmodels'
    recordset right to it's end on its first go (remember this is all contained
    within a horiz/vertical looper) so when it gets past filling the first
    selectbox the conditions are never correct to allow it to fill the rest of
    the select boxes. Is there a method of returning the recordset to its start
    position? If I were to reset the record set to its start then it should work
    correctly?

    N.b I played with my original version and discovered that if I put a 'duff'
    record at the end of the recordset so that 'I know' that the LAST items to
    be tested will produce a false (and not run the code) it works as expected
    WTF?

    I'm losing it now and failing horribly to explain have a look at a test page
    (n.b please no comments on anything other than this problem (this is still a
    work in progress) (unless you know how to fix the menu to stop it going
    under some of the other page items

    [url]http://www.dyslexicfingars.net/ultratek/sunbedsall.asp[/url]

    n.b. This page (currently) has the version with the 'IF' statement in it and
    works - but only for the first selectbox.

    Cheers

    Dyslexic


    Dyslexic Guest

  7. #6

    Default Re: recordset while loop problem

    "Dyslexic" wrote
    > This code works perfectly within its own rights but does not give my
    desired
    > results because the 'do until' loop takes the 'pullallmanhorizmodels'
    > recordset right to it's end on its first go (remember this is all
    contained
    > within a horiz/vertical looper) so when it gets past filling the first
    > selectbox the conditions are never correct to allow it to fill the rest of
    > the select boxes. Is there a method of returning the recordset to its
    start
    > position? If I were to reset the record set to its start then it should
    work
    > correctly?
    Actually, that was why I used 'do ... loop' -
    because you can use "exit do". I don't think
    you can do that with "while".

    do until pullallmanhorizmodels.EOF
    if pullallmanhorizmodels("manufacturer")
    = allsunbedman("manufacturer") then
    %><option value= ---etc--- </option><%
    else
    exit do
    end if
    pullallmanhorizmodels.MoveNext
    loop
    > N.b I played with my original version and discovered that if I put a
    'duff'
    > record at the end of the recordset so that 'I know' that the LAST items to
    > be tested will produce a false (and not run the code) it works as expected
    > WTF?
    If you have an expression like -

    True and False and True and True

    All languages have rules about whether to evaluate the whole expression
    or just until the first 'False'.

    I can't remember what VB does (or even what this is called),
    but I guess it does the whole line.

    So with -

    NOT pullallmanhorizmodels.EOF AND pullallmanhorizmodels("manufacturer") =
    allsunbedman("manufacturer")


    The EOF has been reached but it still tries to evaluate
    the next part of the expression.

    If you run your original code again, and then do "view source"
    on the web page, perhaps the error message is at the bottom
    of the page.
    > I'm losing it now and failing horribly to explain have a look at a test
    page
    > (n.b please no comments on anything other than this problem (this is still
    a
    > work in progress) (unless you know how to fix the menu to stop it going
    > under some of the other page items
    I don't think you can hide select boxes under other things.

    AFAIK the only way is to use client side script to determine
    when they are partially covered, and then hide the whole box.

    It's messy, and it looks almost as bad.

    You'll save yourself a lot brain ache if you just rearrange the page.

    --
    roger


    roger Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139