disconnected recordsets and eof

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

  1. #1

    Default disconnected recordsets and eof

    I know this may sound stupid, but when you use a disconnected recordset can
    you check for eof or bof, i assume you can just i get an error even when
    checking for this

    I just dim the RS but dont use set creatobject(recordset) i assume this bit
    isn't needed if you arent using a dsn.

    Then i use the following statement

    set RS = conn.execute(SQL) 'set the RS to open SQL statement 1
    if RS.eof or RS.bof then
    'blah blah blah
    else
    do sometbhning
    end if

    But it errors, any ideas why, below is my connection variables do i still
    have to use set rs= server.createobject("adodb.recordset"), i assumed that
    this wasn't needed if you used set rs = conn.execute(sql)

    thanks for your time

    <%
    'The declaration section all the regulary used identifiers are in here
    dim conn 'the variable to hold the conn connection
    dim strconn 'the variable to hold the connection string details
    dim strSQL 'the var for the sql string
    dim physicaldbpath 'the var holding the physical path of the directory.
    Dim RS 'the var for the Recordset
    %>
    <!--#include file="../connection/connstring.inc"-->
    <%
    set conn = server.createobject("adodb.connection") 'sets the var string to
    a db connection
    conn.open strconn 'opens the database
    %>


    Steven Scaife Guest

  2. Similar Questions and Discussions

    1. MSAccess DB disconnected unregulary
      Hi, I've got since two month a strange problem and I try to descibe it here, because I found no solution. I've got an CF MX 6.0 Account on a...
    2. when to use connection method over disconnected recordsets
      When if ever should you use a connected recordset. I am using disconnected recordsets throughout my site as they are quicker, and after learning...
    3. Persisted XML Recordsets - Disconnected Recordsets - problems
      I have a recordset, client side .ASP that I save as a DOM. I pass to a server side .ASP to reconnect the recordset and update. I keep getting an...
    4. ASP HELP -- Disconnected recordset?????
      I am in the process of doing a report and in the report, I'm pulling information from a sql database. Select * from Sales In the Sales table,...
    5. disconnected result set
      hi all, I would like to use a disconnected result set in PHP. I have the following code: $strSql = "select * from table1"; $result =...
  3. #2

    Default Re: disconnected recordsets and eof

    > if RS.eof or RS.bof then

    What is this going to prove, that "if rs.eof then" alone is not? This OR
    check drives me bananas, it's extra code that serves absolutely no purpose
    and often confuses the issue.
    > But it errors, any ideas why
    Of course not. Just like you can't tell me why my car "errors" unless I
    give you more information. Can you tell us the actual error message, maybe?
    And verify the line that it occurs on?

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)


    Aaron [SQL Server MVP] Guest

  4. #3

    Default Re: disconnected recordsets and eof

    I get error

    ADODB.Field (0x80020009)
    Either BOF or EOF is True, or the current record has been deleted. Requested
    operation requires a current record.
    /testing/Search2.asp

    my line of code that it errors on is

    set RS = conn.execute(SQL3) 'set the RS to open SQL statement 3
    if RS.eof then

    Because of the message i put the bof and eof in cos i didn't understand it

    thanks for your time

    "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
    news:OHpi3QzbEHA.2468@TK2MSFTNGP09.phx.gbl...
    > > if RS.eof or RS.bof then
    >
    > What is this going to prove, that "if rs.eof then" alone is not? This OR
    > check drives me bananas, it's extra code that serves absolutely no purpose
    > and often confuses the issue.
    >
    > > But it errors, any ideas why
    >
    > Of course not. Just like you can't tell me why my car "errors" unless I
    > give you more information. Can you tell us the actual error message,
    maybe?
    > And verify the line that it occurs on?
    >
    > --
    > [url]http://www.aspfaq.com/[/url]
    > (Reverse address to reply.)
    >
    >

    Steven Scaife Guest

  5. #4

    Default Re: disconnected recordsets and eof

    Steven Scaife wrote:
    > I know this may sound stupid, but when you use a disconnected
    > recordset can you check for eof or bof, i assume you can just i get
    > an error even when checking for this
    >
    > I just dim the RS but dont use set creatobject(recordset) i assume
    > this bit isn't needed if you arent using a dsn.
    ?? Where did you get this idea? :-)
    The use or non-use of a dsn in your connection's connection string is
    totally irrelevant to the question of whether or not you need to explicitly
    create your ADODB.Recordset object.

    If you use
    Set rs = conn.execute ...
    or
    Set rs = cmd.execute ...

    Then you do not need to explicitly create the ADODB.recordset object since
    the Execute method implicitly creates one behind the scenes.

    If you want to have more control over cursor type, location, etc., then you
    need to explicitly create the object and set these properties before you
    open the recordset.

    >
    > Then i use the following statement
    >
    > set RS = conn.execute(SQL) 'set the RS to open SQL statement 1
    > if RS.eof or RS.bof then
    > 'blah blah blah
    > else
    > do sometbhning
    > end if
    >
    > But it errors, any ideas why, below is my connection variables do i
    > still have to use set rs= server.createobject("adodb.recordset"), i
    > assumed that this wasn't needed if you used set rs = conn.execute(sql)
    That is correct. See above.

    I do not see a disconnected recordset here. A disconnected recordset is a
    recordset that is opened against a data source and then disconnected from
    the data source by setting its ActiveConnection property to Nothing.

    And how do you expect us to troubleshoot an error when we don't know what
    the error is? :-)

    Bob Barrows
    PS. There is no need to test both BOF and EOF immediately after opening the
    recordset. A simple test for EOF will suffice.
    --
    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] Guest

  6. #5

    Default Re: disconnected recordsets and eof

    > I get error
    >
    > ADODB.Field (0x80020009)
    > Either BOF or EOF is True, or the current record has been deleted.
    Requested
    > operation requires a current record.
    > /testing/Search2.asp
    >
    > my line of code that it errors on is
    >
    > set RS = conn.execute(SQL3) 'set the RS to open SQL statement 3
    > if RS.eof then
    Great, now can you show more code!? The error above did not happen on these
    lines unless something really funky happened before it.
    > Because of the message i put the bof and eof in cos i didn't understand it
    Don't just do things BECAUSE you don't understand them. Documentation is
    out there for a reason...

    A


    Aaron [SQL Server MVP] Guest

  7. #6

    Default Re: disconnected recordsets and eof

    Thanks for your help i sorted it, its late in the day and i finding it hard
    to pick up on my mistakes.

    There was a problem with my if statements they should have been nested but
    they weren't.

    Sorry for wasting your time

    although you cleared up the bof eof thingy for me

    ta


    Steven Scaife 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