RS EOF question

Discussion in 'ASP General' started by Mike, Jan 5, 2006.

  1. Mike

    Mike Guest

    I have some simple code see below.

    I have response written out the query and it is valid and returns values
    when ran directly against my db, which is Oracle. My OS is Win 2003.

    My question is I never get to the point of the loop. It always thinks I am
    at the RS.EOF. Similar code works in other asp pages on the same server.
    How do I debug this or am I missing something obvious??

    Thanks
    Mike




    CODE

    Set Conn = Server.CreateObject("ADODB.Connection")

    Conn.Open strConnectString
    Set RS = Conn.Execute(SQL)

    If RS.Eof then
    Response.write "<center><b>"
    response.write "There are no values in the system that match your query."
    Response.write "<br>Please Try Again!"
    response.write "</b><form>"
    response.write "<input type='button' value='Retry' onclick=history.back()>"
    response.write "</form></center>"
    response.end

    Else
    Do While Not RS.EOF
    <stuff>

    RS.MoveNext
    Loop
    End If

    Set RS = Nothing
    Conn.Close : Set Conn = Nothing
    Mike, Jan 5, 2006
    #1
    1. Advertising

  2. Mike

    Slim Guest

    I cant see anything wrong although I always use
    Do until rs.eof

    I cant see hat being the difference.

    I suspect that it is your SQL string you did no post




    "Mike" <> wrote in message
    news:...
    >I have some simple code see below.
    >
    > I have response written out the query and it is valid and returns values
    > when ran directly against my db, which is Oracle. My OS is Win 2003.
    >
    > My question is I never get to the point of the loop. It always thinks I
    > am
    > at the RS.EOF. Similar code works in other asp pages on the same server.
    > How do I debug this or am I missing something obvious??
    >
    > Thanks
    > Mike
    >
    >
    >
    >
    > CODE
    >
    > Set Conn = Server.CreateObject("ADODB.Connection")
    >
    > Conn.Open strConnectString
    > Set RS = Conn.Execute(SQL)
    >
    > If RS.Eof then
    > Response.write "<center><b>"
    > response.write "There are no values in the system that match your query."
    > Response.write "<br>Please Try Again!"
    > response.write "</b><form>"
    > response.write "<input type='button' value='Retry'
    > onclick=history.back()>"
    > response.write "</form></center>"
    > response.end
    >
    > Else
    > Do While Not RS.EOF
    > <stuff>
    >
    > RS.MoveNext
    > Loop
    > End If
    >
    > Set RS = Nothing
    > Conn.Close : Set Conn = Nothing
    Slim, Jan 5, 2006
    #2
    1. Advertising

  3. Mike

    Mike Guest

    The result of this code:

    Set RS = Conn.Execute(SQL)

    response.write rs.bof & " rs.bof <br>"
    response.write rs.eof & " rs.eof <br>"

    is
    True rs.bof
    True rs.eof


    "Mike" wrote:

    > I have some simple code see below.
    >
    > I have response written out the query and it is valid and returns values
    > when ran directly against my db, which is Oracle. My OS is Win 2003.
    >
    > My question is I never get to the point of the loop. It always thinks I am
    > at the RS.EOF. Similar code works in other asp pages on the same server.
    > How do I debug this or am I missing something obvious??
    >
    > Thanks
    > Mike
    >
    >
    >
    >
    > CODE
    >
    > Set Conn = Server.CreateObject("ADODB.Connection")
    >
    > Conn.Open strConnectString
    > Set RS = Conn.Execute(SQL)
    >
    > If RS.Eof then
    > Response.write "<center><b>"
    > response.write "There are no values in the system that match your query."
    > Response.write "<br>Please Try Again!"
    > response.write "</b><form>"
    > response.write "<input type='button' value='Retry' onclick=history.back()>"
    > response.write "</form></center>"
    > response.end
    >
    > Else
    > Do While Not RS.EOF
    > <stuff>
    >
    > RS.MoveNext
    > Loop
    > End If
    >
    > Set RS = Nothing
    > Conn.Close : Set Conn = Nothing
    Mike, Jan 5, 2006
    #3
  4. Mike wrote:
    > The result of this code:
    >
    > Set RS = Conn.Execute(SQL)
    >
    > response.write rs.bof & " rs.bof <br>"
    > response.write rs.eof & " rs.eof <br>"
    >
    > is
    > True rs.bof
    > True rs.eof
    >
    >


    This obviously means that your query is not returning any records. To debug
    it (assuming you are using <ugh!!> dynamic sql) you need to

    Response.Write SQL
    Response.End

    run the page and look at the statement in the browser window. If you've
    created it correctly, you should be able to copy it to the clipboard from
    the browser window and paste it into the query execution tool for whatever
    database you are using and test it.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jan 5, 2006
    #4
  5. Mike

    Patrice Guest

    Looks good. You could copy/paste the SQL string to make sure you running the
    same query. Try also to use the full name for the object or a simple
    COUNT(*) request. I suspect that you don't query against the same data...
    --
    Patrice

    "Mike" <> a écrit dans le message de
    news:...
    > I have some simple code see below.
    >
    > I have response written out the query and it is valid and returns values
    > when ran directly against my db, which is Oracle. My OS is Win 2003.
    >
    > My question is I never get to the point of the loop. It always thinks I

    am
    > at the RS.EOF. Similar code works in other asp pages on the same server.
    > How do I debug this or am I missing something obvious??
    >
    > Thanks
    > Mike
    >
    >
    >
    >
    > CODE
    >
    > Set Conn = Server.CreateObject("ADODB.Connection")
    >
    > Conn.Open strConnectString
    > Set RS = Conn.Execute(SQL)
    >
    > If RS.Eof then
    > Response.write "<center><b>"
    > response.write "There are no values in the system that match your query."
    > Response.write "<br>Please Try Again!"
    > response.write "</b><form>"
    > response.write "<input type='button' value='Retry'

    onclick=history.back()>"
    > response.write "</form></center>"
    > response.end
    >
    > Else
    > Do While Not RS.EOF
    > <stuff>
    >
    > RS.MoveNext
    > Loop
    > End If
    >
    > Set RS = Nothing
    > Conn.Close : Set Conn = Nothing
    Patrice, Jan 5, 2006
    #5
  6. Mike

    Mike Guest

    As I said in my initial post I did response.write it out and paste it in Toad
    and ran a query against me oracle db and it returns values.

    Here is the query and no I am not using * but I used it for a test and it
    too does not return records. If I use a query Select * from
    Activity_tracking it returns records.

    I just did a test of my query and if I remove the "AND AT_DATE between
    '1-Jan-2005' AND '1-Jan-2007'" it returns values. There is something in the
    between portion that is causing this??

    Mike


    Query
    Select * from Activity_tracking, activities_ICD, Clients, Projects,
    Contracts, methods, curve_definitions, components, runs, ru_cos where
    rc_cd_key = cd_key AND pr_cn_key = cn_key AND cn_cl_key = cl_key AND
    pr_me_key = me_key AND pr_key = cd_pr_key AND cd_co_key = co_key AND pr_key =
    ru_pr_key AND ru_key = rc_ru_key AND AT_RC_RUN_ID = rc_key AND pr_key =
    AT_PR_key AND AI_AT_key = AT_key AND AT_DATE between '1-Jan-2005' AND
    '1-Jan-2007'

    "Bob Barrows [MVP]" wrote:

    > Mike wrote:
    > > The result of this code:
    > >
    > > Set RS = Conn.Execute(SQL)
    > >
    > > response.write rs.bof & " rs.bof <br>"
    > > response.write rs.eof & " rs.eof <br>"
    > >
    > > is
    > > True rs.bof
    > > True rs.eof
    > >
    > >

    >
    > This obviously means that your query is not returning any records. To debug
    > it (assuming you are using <ugh!!> dynamic sql) you need to
    >
    > Response.Write SQL
    > Response.End
    >
    > run the page and look at the statement in the browser window. If you've
    > created it correctly, you should be able to copy it to the clipboard from
    > the browser window and paste it into the query execution tool for whatever
    > database you are using and test it.
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >
    Mike, Jan 5, 2006
    #6
  7. Mike

    Mike Guest

    It's interesting at least to me if I change the date format so that my query
    uses
    AND AT_DATE between '2005-Jan-1' AND '2007-Jan-1' it works from asp but not
    from my Toad client. I wish I was still using MS SQL 2000

    Mike

    "Mike" wrote:

    > As I said in my initial post I did response.write it out and paste it in Toad
    > and ran a query against me oracle db and it returns values.
    >
    > Here is the query and no I am not using * but I used it for a test and it
    > too does not return records. If I use a query Select * from
    > Activity_tracking it returns records.
    >
    > I just did a test of my query and if I remove the "AND AT_DATE between
    > '1-Jan-2005' AND '1-Jan-2007'" it returns values. There is something in the
    > between portion that is causing this??
    >
    > Mike
    >
    >
    > Query
    > Select * from Activity_tracking, activities_ICD, Clients, Projects,
    > Contracts, methods, curve_definitions, components, runs, ru_cos where
    > rc_cd_key = cd_key AND pr_cn_key = cn_key AND cn_cl_key = cl_key AND
    > pr_me_key = me_key AND pr_key = cd_pr_key AND cd_co_key = co_key AND pr_key =
    > ru_pr_key AND ru_key = rc_ru_key AND AT_RC_RUN_ID = rc_key AND pr_key =
    > AT_PR_key AND AI_AT_key = AT_key AND AT_DATE between '1-Jan-2005' AND
    > '1-Jan-2007'
    >
    > "Bob Barrows [MVP]" wrote:
    >
    > > Mike wrote:
    > > > The result of this code:
    > > >
    > > > Set RS = Conn.Execute(SQL)
    > > >
    > > > response.write rs.bof & " rs.bof <br>"
    > > > response.write rs.eof & " rs.eof <br>"
    > > >
    > > > is
    > > > True rs.bof
    > > > True rs.eof
    > > >
    > > >

    > >
    > > This obviously means that your query is not returning any records. To debug
    > > it (assuming you are using <ugh!!> dynamic sql) you need to
    > >
    > > Response.Write SQL
    > > Response.End
    > >
    > > run the page and look at the statement in the browser window. If you've
    > > created it correctly, you should be able to copy it to the clipboard from
    > > the browser window and paste it into the query execution tool for whatever
    > > database you are using and test it.
    > >
    > > Bob Barrows
    > > --
    > > Microsoft MVP -- ASP/ASP.NET
    > > Please reply to the newsgroup. The email account listed in my From
    > > header is my spam trap, so I don't check it very often. You will get a
    > > quicker response by posting to the newsgroup.
    > >
    > >
    > >
    Mike, Jan 5, 2006
    #7
  8. Mike wrote:
    > As I said in my initial post I did response.write it out and paste it
    > in Toad and ran a query against me oracle db and it returns values.


    Oh, sorry, i missed that.
    >
    > Here is the query and no I am not using * but I used it for a test
    > and it too does not return records. If I use a query Select * from
    > Activity_tracking it returns records.
    >
    > I just did a test of my query and if I remove the "AND AT_DATE between
    > '1-Jan-2005' AND '1-Jan-2007'" it returns values. There is something
    > in the between portion that is causing this??
    >


    I'm not familiar with Oracle, but i suspect the date format is causing a
    problem. You should try using the ISO date format (yyyymmdd or yyyy-mm-dd)
    and see if it makes a difference. The OLE DB provider you are using may be
    misinterpreting the dates.
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jan 5, 2006
    #8
  9. Mike

    Mike Guest

    The date format was the issue. From asp it takes one format and from Toad(my
    oracle client) it takes a different format. That's why it was difficult to
    debug.

    Thanks to all

    Mike



    "Bob Barrows [MVP]" wrote:

    > Mike wrote:
    > > As I said in my initial post I did response.write it out and paste it
    > > in Toad and ran a query against me oracle db and it returns values.

    >
    > Oh, sorry, i missed that.
    > >
    > > Here is the query and no I am not using * but I used it for a test
    > > and it too does not return records. If I use a query Select * from
    > > Activity_tracking it returns records.
    > >
    > > I just did a test of my query and if I remove the "AND AT_DATE between
    > > '1-Jan-2005' AND '1-Jan-2007'" it returns values. There is something
    > > in the between portion that is causing this??
    > >

    >
    > I'm not familiar with Oracle, but i suspect the date format is causing a
    > problem. You should try using the ISO date format (yyyymmdd or yyyy-mm-dd)
    > and see if it makes a difference. The OLE DB provider you are using may be
    > misinterpreting the dates.
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >
    Mike, Jan 5, 2006
    #9
    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. SL_McManus

    A question about EOF

    SL_McManus, Dec 3, 2003, in forum: Perl
    Replies:
    1
    Views:
    464
    Jim Gibson
    Dec 4, 2003
  2. entropy123

    Newbie Question: EOF in MS Visual Studio 2003?

    entropy123, Jul 2, 2003, in forum: C Programming
    Replies:
    6
    Views:
    1,803
    entropy123
    Jul 3, 2003
  3. Kobu
    Replies:
    10
    Views:
    597
    Keith Thompson
    Mar 4, 2005
  4. SpreadTooThin

    ifstream eof not reporting eof?

    SpreadTooThin, Jun 13, 2007, in forum: C++
    Replies:
    10
    Views:
    665
    James Kanze
    Jun 15, 2007
  5. Jan Burse
    Replies:
    67
    Views:
    1,020
    Jan Burse
    Mar 14, 2012
Loading...

Share This Page