Professional Web Applications Themes

Set an Empty Recordset? - ASP

You could throw in a rsQuery.Movelast Sometimes what I'll do in testing is: CONST TRAP_STOP = 10 DIM TRAP_COUNT TRAP_COUNT = 1 Do while not whatever.eof TRAP_COUNT = TRAP_COUNT + 1 IF TRAP_COUNT > TRAP_STOP THEN EXIT DO '''other code Loop I'll just throw in some sort of a counter that will stop the code after a certain number of loops so I don't have to wait for 1000 records or something. And the uppercase doesn't indicate constants, necessarily. I just put my temp code in uppercase like that so it's easier to find and delete later. Thank God I ...

  1. #1

    Default Re: Set an Empty Recordset?

    You could throw in a
    rsQuery.Movelast

    Sometimes what I'll do in testing is:

    CONST TRAP_STOP = 10
    DIM TRAP_COUNT
    TRAP_COUNT = 1



    Do while not whatever.eof
    TRAP_COUNT = TRAP_COUNT + 1
    IF TRAP_COUNT > TRAP_STOP THEN EXIT DO
    '''other code
    Loop


    I'll just throw in some sort of a counter that will stop the code after a
    certain number of loops so I don't have to wait for 1000 records or
    something. And the uppercase doesn't indicate constants, necessarily. I
    just put my temp code in uppercase like that so it's easier to find and
    delete later. Thank God I use VB Script...

    Ray at work





    "Bill" <nowherefooemail.com> wrote in message
    news:OTNNK0fVDHA.1744TK2MSFTNGP12.phx.gbl...
    > Set rsQuery = Server.CreateObject("ADODB.Connection")
    > Set rsQuery = Conn.Execute(<SQL Commands>)
    >
    > (some error testing)
    >
    > Do While NOT rsQuery.EOF
    > .......
    >
    > This isn't indicative of the actual code, but it's what's happening.
    >
    > During the (some error testing), depending upon some external parameters I
    > may want to set the recordset rsQuery to be an empty record. I've tried
    > setting it to an empty string, null, or nothing. These give me an error at
    > the rsQuery.EOF statement.
    >
    > How do I set the rsQuery recordset to be empty so that it will skip the Do
    > While loop?
    >
    > ba
    >
    >
    >
    >
    >

    Ray at Guest

  2. #2

    Default Re: Set an Empty Recordset?

    Bill wrote:
    > Set rsQuery = Server.CreateObject("ADODB.Connection")
    > Set rsQuery = Conn.Execute(<SQL Commands>)
    >
    > (some error testing)
    >
    > Do While NOT rsQuery.EOF
    > .......
    >
    > This isn't indicative of the actual code, but it's what's happening.
    >
    > During the (some error testing), depending upon some external
    > parameters I may want to set the recordset rsQuery to be an empty
    > record. I've tried setting it to an empty string, null, or nothing.
    > These give me an error at the rsQuery.EOF statement.
    >
    > How do I set the rsQuery recordset to be empty so that it will skip
    > the Do While loop?
    >
    > ba
    You can't "set" it to be empty. I think it would be better to use
    If...Else....End if logic to bypass your loop. Maybe set a variable to true
    or false during the "some error testing" and then check the variable's value
    before running the loop ...

    HTH,
    Bob Barrows


    Bob Barrows Guest

  3. #3

    Default Re: Set an Empty Recordset?

    Ray at <%=sLocation%> wrote:
    > You could throw in a
    > rsQuery.Movelast
    >
    That won't work on a forward-only cursor. The cursor needs to support
    bookmarks or MovePrevious in order for MoveLast to be supported.

    Even if you had a scrollable cursor, using MoveLast by itself will not set
    EOF to True: you need to follow it by a MoveNext statement, which will set
    EOF to True.

    Bob


    Bob Barrows Guest

  4. #4

    Default Re: Set an Empty Recordset?

    Empty and closed or empty and open? A recordset can be either I think.
    To be empty in either state it must actually first *exist*, so you'd have to
    create it using createobject.

    If you just want to simulate returning no records then just use some SQL
    which will return no records

    eg

    select * from tablename where 1=2

    Tim.



    "Bill" <nowherefooemail.com> wrote in message
    news:OTNNK0fVDHA.1744TK2MSFTNGP12.phx.gbl...
    > Set rsQuery = Server.CreateObject("ADODB.Connection")
    > Set rsQuery = Conn.Execute(<SQL Commands>)
    >
    > (some error testing)
    >
    > Do While NOT rsQuery.EOF
    > .......
    >
    > This isn't indicative of the actual code, but it's what's happening.
    >
    > During the (some error testing), depending upon some external parameters I
    > may want to set the recordset rsQuery to be an empty record. I've tried
    > setting it to an empty string, null, or nothing. These give me an error at
    > the rsQuery.EOF statement.
    >
    > How do I set the rsQuery recordset to be empty so that it will skip the Do
    > While loop?
    >
    > ba
    >
    >
    >
    >
    >

    Tim Williams Guest

  5. #5

    Default Re: Set an Empty Recordset?

    Try changing
    Do While NOT rsQuery.EOF
    to
    Do While NOT IsEmpty(rsQuery)

    HTH
    Steve

    "Bill" <nowherefooemail.com> wrote in message
    news:OTNNK0fVDHA.1744TK2MSFTNGP12.phx.gbl...
    > Set rsQuery = Server.CreateObject("ADODB.Connection")
    > Set rsQuery = Conn.Execute(<SQL Commands>)
    >
    > (some error testing)
    >
    > Do While NOT rsQuery.EOF
    > .......
    >
    > This isn't indicative of the actual code, but it's what's happening.
    >
    > During the (some error testing), depending upon some external parameters I
    > may want to set the recordset rsQuery to be an empty record. I've tried
    > setting it to an empty string, null, or nothing. These give me an error at
    > the rsQuery.EOF statement.
    >
    > How do I set the rsQuery recordset to be empty so that it will skip the Do
    > While loop?
    >
    > ba
    >
    >
    >
    >
    >

    Steve Guest

Similar Threads

  1. Show region if recordset is not empty
    By faiz2000 in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: September 4th, 08:13 PM
  2. Show if recordset is empty??
    By longsdale in forum Dreamweaver AppDev
    Replies: 4
    Last Post: April 1st, 04:37 PM
  3. Replies: 0
    Last Post: October 16th, 05:19 AM
  4. Replies: 0
    Last Post: October 15th, 06:20 PM
  5. Load Empty Recordset
    By Gary D. Rezek in forum ASP Database
    Replies: 4
    Last Post: July 30th, 01:36 AM

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