469,304 Members | 1,888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

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.
Jul 19 '05 #1
4 3807
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" <br***********@excite.com> wrote in message
news:42**************************@posting.google.c om...
: 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.
Jul 19 '05 #2
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"
Jul 19 '05 #3
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" <re******@NOyahoo.SPAMcom> wrote in message news:<uJ**************@TK2MSFTNGP12.phx.gbl>...
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

Jul 19 '05 #4
I believe I figured this one out....thanks again.

Bryan
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message news:<uJ**************@TK2MSFTNGP12.phx.gbl>...
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

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Rahul Chatterjee | last post: by
2 posts views Thread by Steve Marciniak | last post: by
6 posts views Thread by Jennifer Smith | last post: by
22 posts views Thread by Gerry Abbott | last post: by
reply views Thread by Thaddeus | last post: by
1 post views Thread by blueheelers | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.