displaying recordset in columns.....

Discussion in 'ASP General' started by Bryan, Nov 28, 2003.

  1. Bryan

    Bryan Guest

    I have a results table that is 5 columns wide. the recordset is
    returned with 48 items. I have no problem displaying 5 per row until I
    hit the last row where i get a ADODB.Field error '80020009'

    Either BOF or EOF is True, or the current record has been deleted.
    Requested operation requires a current record.

    My question is how do I close of the table row when I reach the EOF?

    i.e

    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 * *

    I need to display empty cells (in place of the *'s)or end the row when
    there is no data to fill it...how is this done?

    Thank you.
    Bryan, Nov 28, 2003
    #1
    1. Advertising

  2. Bryan

    Ken Schaefer Guest

    Before you write *any* of the records, you need to test for .EOF again. If
    it's .EOF then continue writing out the rest of the table row with just
    <td>&nbsp;</td>, otherwise write out the current record. For te next record,
    test for .EOF *again*

    Cheers
    Ken


    "Bryan" <> wrote in message
    news:...
    : I have a results table that is 5 columns wide. the recordset is
    : returned with 48 items. I have no problem displaying 5 per row until I
    : hit the last row where i get a ADODB.Field error '80020009'
    :
    : Either BOF or EOF is True, or the current record has been deleted.
    : Requested operation requires a current record.
    :
    : My question is how do I close of the table row when I reach the EOF?
    :
    : i.e
    :
    : 1 2 3 4 5
    : 1 2 3 4 5
    : 1 2 3 4 5
    : 1 2 3 4 5
    : 1 2 3 4 5
    : 1 2 3 * *
    :
    : I need to display empty cells (in place of the *'s)or end the row when
    : there is no data to fill it...how is this done?
    :
    : Thank you.
    Ken Schaefer, Nov 28, 2003
    #2
    1. Advertising

  3. Bryan

    Bob Barrows Guest

    Bryan wrote:
    > I have a results table that is 5 columns wide. the recordset is
    > returned with 48 items. I have no problem displaying 5 per row until I
    > hit the last row where i get a ADODB.Field error '80020009'
    >
    > Either BOF or EOF is True, or the current record has been deleted.
    > Requested operation requires a current record.
    >
    > My question is how do I close of the table row when I reach the EOF?
    >
    > i.e
    >
    > 1 2 3 4 5
    > 1 2 3 4 5
    > 1 2 3 4 5
    > 1 2 3 4 5
    > 1 2 3 4 5
    > 1 2 3 * *
    >
    > I need to display empty cells (in place of the *'s)or end the row when
    > there is no data to fill it...how is this done?
    >
    > Thank you.


    Just a variation on Ken's suggestion.

    dim rs,arData,,i,iRow,iRows, iRecords
    'After opening the recordset, do this:
    If not rs.EOF then arData = rs.GetRows
    rs.Close: Set rs=nothing
    'close and destroy the connection as well

    if isarray(arData) then
    response.write "<table rules=cols " & _
    "style=""border-collapse:collapse;width:200px"">"
    Response.Write "<COL width=""40"">"
    Response.Write "<COL width=""40"">"
    Response.Write "<COL width=""40"">"
    Response.Write "<COL width=""40"">"
    Response.Write "<COL width=""40"">"
    'determine the number of table rows
    iRecords = ubound(arData,2)+1
    iRows = Int(iRecords/5)
    if iRows < iRecords/5 then
    iRows = iRows + 1
    end if
    for iRow = 0 to iRows -1
    Response.Write "<tr>"
    for i = iRow * 5 to iRow * 5 + 4
    Response.Write "<td>"
    if i <= ubound(arData,2) then
    Response.Write arData(0,i)
    else
    Response.Write "&nbsp;"
    end if
    Response.Write "</td>"
    next 'i
    Response.Write "</tr>"
    next 'iRow
    response.write "</table>"
    else
    response.write "no records were returned"
    end if

    HTH,
    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows, Nov 28, 2003
    #3
  4. Bryan

    Bryan Guest

    Thank you Bob,

    but I can't seem to figure out where to insert my results info into
    your code....

    I can implement the code and it gives me a great display like

    12345
    67

    but if I am trying to display images with titles where would I place
    the calls for this information?

    Thank you for your help


    "Bob Barrows" <> wrote in message news:<>...
    > Bryan wrote:
    > > I have a results table that is 5 columns wide. the recordset is
    > > returned with 48 items. I have no problem displaying 5 per row until I
    > > hit the last row where i get a ADODB.Field error '80020009'
    > >
    > > Either BOF or EOF is True, or the current record has been deleted.
    > > Requested operation requires a current record.
    > >
    > > My question is how do I close of the table row when I reach the EOF?
    > >
    > > i.e
    > >
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 * *
    > >
    > > I need to display empty cells (in place of the *'s)or end the row when
    > > there is no data to fill it...how is this done?
    > >
    > > Thank you.

    >
    > Just a variation on Ken's suggestion.
    >
    > dim rs,arData,,i,iRow,iRows, iRecords
    > 'After opening the recordset, do this:
    > If not rs.EOF then arData = rs.GetRows
    > rs.Close: Set rs=nothing
    > 'close and destroy the connection as well
    >
    > if isarray(arData) then
    > response.write "<table rules=cols " & _
    > "style=""border-collapse:collapse;width:200px"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > 'determine the number of table rows
    > iRecords = ubound(arData,2)+1
    > iRows = Int(iRecords/5)
    > if iRows < iRecords/5 then
    > iRows = iRows + 1
    > end if
    > for iRow = 0 to iRows -1
    > Response.Write "<tr>"
    > for i = iRow * 5 to iRow * 5 + 4
    > Response.Write "<td>"
    > if i <= ubound(arData,2) then
    > Response.Write arData(0,i)
    > else
    > Response.Write "&nbsp;"
    > end if
    > Response.Write "</td>"
    > next 'i
    > Response.Write "</tr>"
    > next 'iRow
    > response.write "</table>"
    > else
    > response.write "no records were returned"
    > end if
    >
    > HTH,
    > Bob Barrows
    Bryan, Dec 1, 2003
    #4
  5. Bryan

    Bryan Guest

    I believe I figured this one out....thanks again.

    Bryan


    "Bob Barrows" <> wrote in message news:<>...
    > Bryan wrote:
    > > I have a results table that is 5 columns wide. the recordset is
    > > returned with 48 items. I have no problem displaying 5 per row until I
    > > hit the last row where i get a ADODB.Field error '80020009'
    > >
    > > Either BOF or EOF is True, or the current record has been deleted.
    > > Requested operation requires a current record.
    > >
    > > My question is how do I close of the table row when I reach the EOF?
    > >
    > > i.e
    > >
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 4 5
    > > 1 2 3 * *
    > >
    > > I need to display empty cells (in place of the *'s)or end the row when
    > > there is no data to fill it...how is this done?
    > >
    > > Thank you.

    >
    > Just a variation on Ken's suggestion.
    >
    > dim rs,arData,,i,iRow,iRows, iRecords
    > 'After opening the recordset, do this:
    > If not rs.EOF then arData = rs.GetRows
    > rs.Close: Set rs=nothing
    > 'close and destroy the connection as well
    >
    > if isarray(arData) then
    > response.write "<table rules=cols " & _
    > "style=""border-collapse:collapse;width:200px"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > Response.Write "<COL width=""40"">"
    > 'determine the number of table rows
    > iRecords = ubound(arData,2)+1
    > iRows = Int(iRecords/5)
    > if iRows < iRecords/5 then
    > iRows = iRows + 1
    > end if
    > for iRow = 0 to iRows -1
    > Response.Write "<tr>"
    > for i = iRow * 5 to iRow * 5 + 4
    > Response.Write "<td>"
    > if i <= ubound(arData,2) then
    > Response.Write arData(0,i)
    > else
    > Response.Write "&nbsp;"
    > end if
    > Response.Write "</td>"
    > next 'i
    > Response.Write "</tr>"
    > next 'iRow
    > response.write "</table>"
    > else
    > response.write "no records were returned"
    > end if
    >
    > HTH,
    > Bob Barrows
    Bryan, Dec 1, 2003
    #5
    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. Kevin Munro

    Null columns in recordset

    Kevin Munro, Nov 7, 2003, in forum: Java
    Replies:
    5
    Views:
    4,123
    Kevin Munro
    Nov 11, 2003
  2. Bill
    Replies:
    2
    Views:
    111
    Andrew Durstewitz
    Jul 9, 2003
  3. Hung Huynh
    Replies:
    8
    Views:
    289
    Bob Barrows
    Sep 24, 2003
  4. Ken Fine
    Replies:
    4
    Views:
    133
    Evertjan.
    Apr 5, 2004
  5. shank

    Display recordset in columns

    shank, Mar 14, 2008, in forum: ASP General
    Replies:
    1
    Views:
    351
    Bob Barrows [MVP]
    Mar 14, 2008
Loading...

Share This Page