displaying recordset in columns.....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bryan

    displaying recordset in columns.....

    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

    #2
    Re: displaying recordset in columns.....

    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" <bryan.bedford@ excite.com> wrote in message
    news:4281c4f9.0 311272036.164f1 6cd@posting.goo gle.com...
    : 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.


    Comment

    • Bob Barrows

      #3
      Re: displaying recordset in columns.....

      Bryan wrote:[color=blue]
      > 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.[/color]

      Just a variation on Ken's suggestion.

      dim rs,arData,,i,iR ow,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=""bo rder-collapse:collap se;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"


      Comment

      • Bryan

        #4
        Re: displaying recordset in columns.....

        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" <reb01501@NOyah oo.SPAMcom> wrote in message news:<uJkKNUbtD HA.2492@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
        > Bryan wrote:[color=green]
        > > 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.[/color]
        >
        > Just a variation on Ken's suggestion.
        >
        > dim rs,arData,,i,iR ow,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=""bo rder-collapse:collap se;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[/color]

        Comment

        • Bryan

          #5
          Re: displaying recordset in columns.....

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

          Bryan


          "Bob Barrows" <reb01501@NOyah oo.SPAMcom> wrote in message news:<uJkKNUbtD HA.2492@TK2MSFT NGP12.phx.gbl>. ..[color=blue]
          > Bryan wrote:[color=green]
          > > 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.[/color]
          >
          > Just a variation on Ken's suggestion.
          >
          > dim rs,arData,,i,iR ow,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=""bo rder-collapse:collap se;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[/color]

          Comment

          Working...