Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > displaying recordset in columns.....

Reply
Thread Tools

displaying recordset in columns.....

 
 
Bryan
Guest
Posts: n/a
 
      11-28-2003
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.
 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      11-28-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.


 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      11-28-2003
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"


 
Reply With Quote
 
Bryan
Guest
Posts: n/a
 
      12-01-2003
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" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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

 
Reply With Quote
 
Bryan
Guest
Posts: n/a
 
      12-01-2003
I believe I figured this one out....thanks again.

Bryan


"Bob Barrows" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying recordset value if it's there Joey Martin ASP General 1 06-24-2009 02:53 PM
Displaying recordset with items grouped by year/month? Ken Fine ASP General 4 04-05-2004 08:03 AM
RecordSet.Move or RecordSet.AbsolutePosition?? Hung Huynh ASP General 8 09-24-2003 11:07 AM
win32 adodb/mdb; con.execute returns undef and not recordset. Vikas Yadav Perl 0 09-09-2003 09:10 AM
Inserting text box into a form, displaying values from recordset Bill ASP General 2 07-09-2003 07:46 PM



Advertisments