Professional Web Applications Themes

Cannot re-read Recordset?? - ASP Components

Here is my code: Set exam = Server.CreateObject("ADODB.Recordset") strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver") & "','" & request("book") & "'" exam.Open strSQL, Connect do until exam.eof%> Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational: <%=exam("rational")%><br> Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational: <%=exam("rational")%><br> <% exam.movenext loop %> The second answer line doesnt display the exam("rational"), but does display exam("answer") and exam("correct"). The data type of this field is text length 16. THANK YOU! -- David Lozzi Web Applications/Network Specialist Delphi Technology Solutions, Inc. [url]www.delphi-ts.com[/url] [email]dlozzidelphi-ts.com[/email] I should've known that, but I had a brain ......

  1. #1

    Default Cannot re-read Recordset??

    Here is my code:

    Set exam = Server.CreateObject("ADODB.Recordset")
    strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver") &
    "','" & request("book") & "'"
    exam.Open strSQL, Connect

    do until exam.eof%>
    Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    <%=exam("rational")%><br>
    Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    <%=exam("rational")%><br>
    <% exam.movenext
    loop %>

    The second answer line doesnt display the exam("rational"), but does display
    exam("answer") and exam("correct"). The data type of this field is text
    length 16.

    THANK YOU!

    --
    David Lozzi
    Web Applications/Network Specialist
    Delphi Technology Solutions, Inc.
    [url]www.delphi-ts.com[/url]
    [email]dlozzidelphi-ts.com[/email]

    I should've known that, but I had a brain ...


    David Lozzi Guest

  2. #2

    Default Cannot re-read Recordset??

    Here is my code:

    Set exam = Server.CreateObject("ADODB.Recordset")
    strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver") &
    "','" & request("book") & "'"
    exam.Open strSQL, Connect

    do until exam.eof%>
    Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    <%=exam("rational")%><br>
    Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    <%=exam("rational")%><br>
    <% exam.movenext
    loop %>

    The second answer line doesnt display the exam("rational"), but does display
    exam("answer") and exam("correct"). The data type of this field is text
    length 16.

    THANK YOU!

    --
    David Lozzi
    Web Applications/Network Specialist
    Delphi Technology Solutions, Inc.
    [url]www.delphi-ts.com[/url]
    [email]dlozzidelphi-ts.com[/email]

    I should've known that, but I had a brain ...


    David Lozzi Guest

  3. #3

    Default Re: Cannot re-read Recordset??

    [url]http://www.aspfaq.com/2188[/url]
    [url]http://www.aspfaq.com/2191[/url]

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "David Lozzi" <dlozzidelphi-ts.com> wrote in message
    news:OALmVmP5DHA.1292TK2MSFTNGP11.phx.gbl...
    > Here is my code:
    >
    > Set exam = Server.CreateObject("ADODB.Recordset")
    > strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver")
    &
    > "','" & request("book") & "'"
    > exam.Open strSQL, Connect
    >
    > do until exam.eof%>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > <% exam.movenext
    > loop %>
    >
    > The second answer line doesnt display the exam("rational"), but does
    display
    > exam("answer") and exam("correct"). The data type of this field is text
    > length 16.
    >
    > THANK YOU!
    >
    > --
    > David Lozzi
    > Web Applications/Network Specialist
    > Delphi Technology Solutions, Inc.
    > [url]www.delphi-ts.com[/url]
    > [email]dlozzidelphi-ts.com[/email]
    >
    > I should've known that, but I had a brain ...
    >
    >

    Aaron Bertrand - MVP Guest

  4. #4

    Default Re: Cannot re-read Recordset??

    [url]http://www.aspfaq.com/2188[/url]
    [url]http://www.aspfaq.com/2191[/url]

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "David Lozzi" <dlozzidelphi-ts.com> wrote in message
    news:OALmVmP5DHA.1292TK2MSFTNGP11.phx.gbl...
    > Here is my code:
    >
    > Set exam = Server.CreateObject("ADODB.Recordset")
    > strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver")
    &
    > "','" & request("book") & "'"
    > exam.Open strSQL, Connect
    >
    > do until exam.eof%>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > <% exam.movenext
    > loop %>
    >
    > The second answer line doesnt display the exam("rational"), but does
    display
    > exam("answer") and exam("correct"). The data type of this field is text
    > length 16.
    >
    > THANK YOU!
    >
    > --
    > David Lozzi
    > Web Applications/Network Specialist
    > Delphi Technology Solutions, Inc.
    > [url]www.delphi-ts.com[/url]
    > [email]dlozzidelphi-ts.com[/email]
    >
    > I should've known that, but I had a brain ...
    >
    >

    Aaron Bertrand - MVP Guest

  5. #5

    Default Re: Cannot re-read Recordset??

    This issue is being answered in a separate thread in an ASP group. Please
    don't post to every technology group on the server...

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "David Lozzi" <dlozzidelphi-ts.com> wrote in message
    news:OALmVmP5DHA.1292TK2MSFTNGP11.phx.gbl...
    > Here is my code:
    >
    > Set exam = Server.CreateObject("ADODB.Recordset")
    > strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver")
    &
    > "','" & request("book") & "'"
    > exam.Open strSQL, Connect
    >
    > do until exam.eof%>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > <% exam.movenext
    > loop %>
    >
    > The second answer line doesnt display the exam("rational"), but does
    display
    > exam("answer") and exam("correct"). The data type of this field is text
    > length 16.
    >
    > THANK YOU!
    >
    > --
    > David Lozzi
    > Web Applications/Network Specialist
    > Delphi Technology Solutions, Inc.
    > [url]www.delphi-ts.com[/url]
    > [email]dlozzidelphi-ts.com[/email]
    >
    > I should've known that, but I had a brain ...
    >
    >

    Aaron Bertrand - MVP Guest

  6. #6

    Default Re: Cannot re-read Recordset??

    This issue is being answered in a separate thread in an ASP group. Please
    don't post to every technology group on the server...

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "David Lozzi" <dlozzidelphi-ts.com> wrote in message
    news:OALmVmP5DHA.1292TK2MSFTNGP11.phx.gbl...
    > Here is my code:
    >
    > Set exam = Server.CreateObject("ADODB.Recordset")
    > strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver")
    &
    > "','" & request("book") & "'"
    > exam.Open strSQL, Connect
    >
    > do until exam.eof%>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    > <%=exam("rational")%><br>
    > <% exam.movenext
    > loop %>
    >
    > The second answer line doesnt display the exam("rational"), but does
    display
    > exam("answer") and exam("correct"). The data type of this field is text
    > length 16.
    >
    > THANK YOU!
    >
    > --
    > David Lozzi
    > Web Applications/Network Specialist
    > Delphi Technology Solutions, Inc.
    > [url]www.delphi-ts.com[/url]
    > [email]dlozzidelphi-ts.com[/email]
    >
    > I should've known that, but I had a brain ...
    >
    >

    Aaron Bertrand - MVP Guest

  7. #7

    Default Re: Cannot re-read Recordset??

    If I'm not mistaken, it cannot display the second one because it
    hasn't got there yet. You can't display two records then "move next".
    You have to display only one record then do the "move next".

    So I think you need this:

    <% do until exam.eof %>
    Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> |
    Rational:
    <%=exam("rational")%><br>
    <% exam.movenext %>
    <% loop %>

    --

    Phillip Windell [CCNA, MVP, MCP]
    WAND-TV (ABC Affiliate)
    [url]www.wandtv.com[/url]

    "David Lozzi" <dlozzidelphi-ts.com> wrote in message
    news:OALmVmP5DHA.1292TK2MSFTNGP11.phx.gbl...
    > Here is my code:
    >
    > Set exam = Server.CreateObject("ADODB.Recordset")
    > strSQL = "p_exam_results_user '" & session("id") & "','" &
    request("ver") &
    > "','" & request("book") & "'"
    > exam.Open strSQL, Connect
    >
    > do until exam.eof%>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> |
    Rational:
    > <%=exam("rational")%><br>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> |
    Rational:
    > <%=exam("rational")%><br>
    > <% exam.movenext
    > loop %>
    >
    > The second answer line doesnt display the exam("rational"), but does
    display
    > exam("answer") and exam("correct"). The data type of this field is
    text
    > length 16.
    >
    > THANK YOU!
    >
    > --
    > David Lozzi
    > Web Applications/Network Specialist
    > Delphi Technology Solutions, Inc.
    > [url]www.delphi-ts.com[/url]
    > [email]dlozzidelphi-ts.com[/email]
    >
    > I should've known that, but I had a brain ...
    >
    >

    Phillip Windell Guest

  8. #8

    Default Re: Cannot re-read Recordset??

    If I'm not mistaken, it cannot display the second one because it
    hasn't got there yet. You can't display two records then "move next".
    You have to display only one record then do the "move next".

    So I think you need this:

    <% do until exam.eof %>
    Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> |
    Rational:
    <%=exam("rational")%><br>
    <% exam.movenext %>
    <% loop %>

    --

    Phillip Windell [CCNA, MVP, MCP]
    WAND-TV (ABC Affiliate)
    [url]www.wandtv.com[/url]

    "David Lozzi" <dlozzidelphi-ts.com> wrote in message
    news:OALmVmP5DHA.1292TK2MSFTNGP11.phx.gbl...
    > Here is my code:
    >
    > Set exam = Server.CreateObject("ADODB.Recordset")
    > strSQL = "p_exam_results_user '" & session("id") & "','" &
    request("ver") &
    > "','" & request("book") & "'"
    > exam.Open strSQL, Connect
    >
    > do until exam.eof%>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> |
    Rational:
    > <%=exam("rational")%><br>
    > Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> |
    Rational:
    > <%=exam("rational")%><br>
    > <% exam.movenext
    > loop %>
    >
    > The second answer line doesnt display the exam("rational"), but does
    display
    > exam("answer") and exam("correct"). The data type of this field is
    text
    > length 16.
    >
    > THANK YOU!
    >
    > --
    > David Lozzi
    > Web Applications/Network Specialist
    > Delphi Technology Solutions, Inc.
    > [url]www.delphi-ts.com[/url]
    > [email]dlozzidelphi-ts.com[/email]
    >
    > I should've known that, but I had a brain ...
    >
    >

    Phillip Windell Guest

  9. #9

    Default Re: Cannot re-read Recordset??

    "David Lozzi" wrote:

    : Set exam = Server.CreateObject("ADODB.Recordset")
    : strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver")
    &
    : "','" & request("book") & "'"
    : exam.Open strSQL, Connect
    :
    : do until exam.eof%>
    : Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    : <%=exam("rational")%><br>
    : Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    : <%=exam("rational")%><br>
    : <% exam.movenext
    : loop %>
    :
    : The second answer line doesnt display the exam("rational"), but does
    display
    : exam("answer") and exam("correct"). The data type of this field is text
    : length 16.

    I don't know why you'd want to return the same record twice but if it is
    exiting your loop prematurely, then perhaps it is doing what it is told to
    do.

    Instead of:
    do until exam.eof

    Try:
    do while not exam.eof

    You could also use exam.getrows which would return a two-dimensional array
    and then you could just use a FOR...NEXT loop.
    dim examResults, i
    examResults = exam.getrows
    for i = lbound(examResults) to ubound(examResults)
    Response.Write("Answer: " & examResults(0, i) & " | Correct: " &
    examResults(1, i) & " | Rational: " & examResults(2, i) & "<br />" & vbCrLf)
    next

    If you wanted to display two at a time, then you could use two Response line
    with i+1 on the 2nd and in your for...next loop, use step 2. You would have
    to test to make sure you had an even number of rows otherwise if it returned
    an odd number, you'd get an error trying to display the last one.

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Doentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

  10. #10

    Default Re: Cannot re-read Recordset??

    "David Lozzi" wrote:

    : Set exam = Server.CreateObject("ADODB.Recordset")
    : strSQL = "p_exam_results_user '" & session("id") & "','" & request("ver")
    &
    : "','" & request("book") & "'"
    : exam.Open strSQL, Connect
    :
    : do until exam.eof%>
    : Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    : <%=exam("rational")%><br>
    : Answer: <%=exam("answer")%> | Correct: <%=exam("correct")%> | Rational:
    : <%=exam("rational")%><br>
    : <% exam.movenext
    : loop %>
    :
    : The second answer line doesnt display the exam("rational"), but does
    display
    : exam("answer") and exam("correct"). The data type of this field is text
    : length 16.

    I don't know why you'd want to return the same record twice but if it is
    exiting your loop prematurely, then perhaps it is doing what it is told to
    do.

    Instead of:
    do until exam.eof

    Try:
    do while not exam.eof

    You could also use exam.getrows which would return a two-dimensional array
    and then you could just use a FOR...NEXT loop.
    dim examResults, i
    examResults = exam.getrows
    for i = lbound(examResults) to ubound(examResults)
    Response.Write("Answer: " & examResults(0, i) & " | Correct: " &
    examResults(1, i) & " | Rational: " & examResults(2, i) & "<br />" & vbCrLf)
    next

    If you wanted to display two at a time, then you could use two Response line
    with i+1 on the 2nd and in your for...next loop, use step 2. You would have
    to test to make sure you had an even number of rows otherwise if it returned
    an odd number, you'd get an error trying to display the last one.

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Doentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

Similar Threads

  1. ADO - Recordset
    By Michael in forum ASP Database
    Replies: 2
    Last Post: March 4th, 09:11 AM
  2. File system get auto change from read-write to read-oly
    By RC in forum Linux / Unix Administration
    Replies: 1
    Last Post: October 23rd, 10:51 PM
  3. Replies: 8
    Last Post: September 24th, 11:07 AM
  4. Read & Read/Write Groups
    By Damien Harrod in forum Sun Solaris
    Replies: 1
    Last Post: July 22nd, 01:52 PM
  5. ORDER BY clause causes read-only recordset
    By Brian in forum Microsoft SQL / MS SQL Server
    Replies: 6
    Last Post: July 9th, 07:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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