Using GetRows()

Discussion in 'ASP General' started by Croney69, Jul 28, 2003.

  1. Croney69

    Croney69 Guest

    I am getting information out of a table to place into to
    an Array.
    rs=DataConn.Execute(strSQL)

    At this point I place it into the array

    objArray=rs.GetRows()

    But how do I handle things if the rs came back blank?

    What happens is that the loop encounters an error?
    Croney69, Jul 28, 2003
    #1
    1. Advertising

  2. Croney69

    Jon Mundsack Guest

    "Croney69" <> wrote in message
    news:004901c3552f$48855f70$...
    > I am getting information out of a table to place into to
    > an Array.
    > rs=DataConn.Execute(strSQL)
    >
    > At this point I place it into the array
    >
    > objArray=rs.GetRows()
    >
    > But how do I handle things if the rs came back blank?
    >
    > What happens is that the loop encounters an error?


    If rs.RecordCount > 0 Then
    objArray = rs.GetRows()
    'do stuff with array
    Else
    'handle "no records" condition
    End If

    HTH-Jon
    Jon Mundsack, Jul 28, 2003
    #2
    1. Advertising

  3. Croney69

    Croney69 Guest

    Sorry I should have mentioned this is a function to
    provide an array, which is then use.

    I am well a wear of the "if then else" and "eof".
    What I want to know is that after calling my function
    MyArray= GetInfo(sql)

    I will know if to proceed or not depending on the result.

    This is what I have seen but it dose not work

    1. If not rs.eof then
    2. ObjArray=rs.GetRows()
    3. Else
    4. ObjArray=dataconn.execute("Select 'EOF'").GetRows()
    5. End if

    I get an error on line 4

    >-----Original Message-----
    >You may want to use If Not rs.EOF Then aVar = rs.GetRows

    () with the code
    >that you're using.
    >
    >Ray at home
    >
    >--
    >Will trade ASP help for SQL Server help
    >
    >
    >"Jon Mundsack" <> wrote in

    message
    >news:bg3nks$kjr3g$-berlin.de...
    >> "Croney69" <> wrote in message
    >> news:004901c3552f$48855f70$...
    >> > I am getting information out of a table to place into

    to
    >> > an Array.
    >> > rs=DataConn.Execute(strSQL)
    >> >
    >> > At this point I place it into the array
    >> >
    >> > objArray=rs.GetRows()
    >> >
    >> > But how do I handle things if the rs came back blank?
    >> >
    >> > What happens is that the loop encounters an error?

    >>
    >> If rs.RecordCount > 0 Then
    >> objArray = rs.GetRows()
    >> 'do stuff with array
    >> Else
    >> 'handle "no records" condition
    >> End If
    >>
    >> HTH-Jon
    >>
    >>
    >>

    >
    >
    >.
    >
    Croney69, Jul 28, 2003
    #3
  4. Croney69

    Jon Mundsack Guest

    "Croney69" <> wrote in message
    news:00ca01c35537$1bf09620$...
    > Sorry I should have mentioned this is a function to
    > provide an array, which is then use.
    >
    > I am well a wear of the "if then else" and "eof".
    > What I want to know is that after calling my function
    > MyArray= GetInfo(sql)
    >
    > I will know if to proceed or not depending on the result.
    >
    > This is what I have seen but it dose not work
    >
    > 1. If not rs.eof then
    > 2. ObjArray=rs.GetRows()
    > 3. Else
    > 4. ObjArray=dataconn.execute("Select 'EOF'").GetRows()
    > 5. End if
    >
    > I get an error on line 4


    So, if rs contains records, you want ObjArray to contain the GetRows, and if
    rs doesn't contain records, you want it to contain a single array element
    holding the word EOF? If so, then this is what you want:

    If not rs.eof then
    ObjArray=rs.GetRows()
    Else
    ReDim ObjArray(0)
    ObjArray(0) = "EOF"
    End if

    I see no reason to involve the dataconn.execute call and another GetRows,
    unless I'm still missing something.

    HTH-Jon
    Jon Mundsack, Jul 28, 2003
    #4
  5. Croney69

    Kris Eiben Guest

    AFAIK you need to select FROM a table or other database object (view,
    stored proc, etc). And, even if that line 4 syntax worked, you'd be
    setting objArray to an array if it had records and a recordset if it
    didn't, which will probably cause problems later.

    I might set it up like this:
    if not rs.EOF then
    objArray = rs.GetRows()
    else
    dim objArray(1,1)
    objArray(0,0) = "No Records" ' or whatever flag value you want
    end if
    Then, I could check objArray(0,0) for "No Records" before processing.

    "Croney69" <> wrote in message
    news:00ca01c35537$1bf09620$...
    > Sorry I should have mentioned this is a function to
    > provide an array, which is then use.
    > I am well a wear of the "if then else" and "eof".
    > What I want to know is that after calling my function
    > MyArray= GetInfo(sql)
    > I will know if to proceed or not depending on the result.
    > This is what I have seen but it dose not work
    > 1. If not rs.eof then
    > 2. ObjArray=rs.GetRows()
    > 3. Else
    > 4. ObjArray=dataconn.execute("Select 'EOF'").GetRows()
    > 5. End if
    >
    > I get an error on line 4
    > >-----Original Message-----
    > >You may want to use If Not rs.EOF Then aVar = rs.GetRows

    > () with the code
    > >that you're using.
    > >Ray at home
    > >--
    > >Will trade ASP help for SQL Server help
    > >"Jon Mundsack" <> wrote in

    > message
    > >news:bg3nks$kjr3g$-berlin.de...
    > >> "Croney69" <> wrote in message
    > >> news:004901c3552f$48855f70$...
    > >> > I am getting information out of a table to place into

    > to
    > >> > an Array.
    > >> > rs=DataConn.Execute(strSQL)
    > >> > At this point I place it into the array
    > >> > objArray=rs.GetRows()
    > >> > But how do I handle things if the rs came back blank?
    > >> > What happens is that the loop encounters an error?
    > >> If rs.RecordCount > 0 Then
    > >> objArray = rs.GetRows()
    > >> 'do stuff with array
    > >> Else
    > >> 'handle "no records" condition
    > >> End If
    > >> HTH-Jon
    Kris Eiben, Jul 28, 2003
    #5
  6. Croney69

    Bob Barrows Guest

    Croney69 wrote:
    > I am getting information out of a table to place into to
    > an Array.
    > rs=DataConn.Execute(strSQL)
    >
    > At this point I place it into the array
    >
    > objArray=rs.GetRows()
    >
    > But how do I handle things if the rs came back blank?
    >
    > What happens is that the loop encounters an error?


    This is my SOP with GetRows:

    if not rs.eof then
    ar=rs.getrows
    end if
    rs.close
    set rs=nothing
    if isarray(ar) then
    'you have data
    else
    'you don't have data
    end if

    HTH,
    Bob Barrows
    Bob Barrows, Jul 28, 2003
    #6
    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. Moshe

    GetRows Mystery

    Moshe, Aug 28, 2003, in forum: ASP General
    Replies:
    8
    Views:
    123
    Bob Barrows
    Aug 28, 2003
  2. Crane Linkledder

    Difference between getrows and getstring

    Crane Linkledder, Oct 29, 2003, in forum: ASP General
    Replies:
    11
    Views:
    253
    Aaron Bertrand - MVP
    Oct 30, 2003
  3. Jim

    GetRows Random <td></td> Output

    Jim, Nov 21, 2003, in forum: ASP General
    Replies:
    1
    Views:
    107
    Jeff Clark
    Nov 22, 2003
  4. Harag

    JScript & GetRows

    Harag, Dec 27, 2003, in forum: ASP General
    Replies:
    4
    Views:
    193
    The Mighty Chaffinch
    Dec 28, 2003
  5. Patrick G.

    Remove items from GetRows array

    Patrick G., Feb 27, 2004, in forum: ASP General
    Replies:
    2
    Views:
    165
    Patrick G.
    Feb 27, 2004
Loading...

Share This Page