displaying recordset in columns.....

B

Bryan

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.
 
K

Ken Schaefer

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


: 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.
 
B

Bob Barrows

Bryan said:
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
 
B

Bryan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top