write results while skipping empty fields?

R

R Keck

I've been away from ASP and ADO/DAO for several years and my books are in
storage in the next state ...

I'm trying to remember some sort of recordset code so that I can not utilize
the webbot database/form tool. What I want to do is display all fields from
a record (about 25 fields, but on average, only 13 are used), but I want to
skip null fields and write out a continuous result to a page that ONLY has
field data and text identifiers for the fields WITH data, and not a bunch of
wasted real estate.

Some how I need to fetch the field data, determine if it's null, then do an
If-then and place the field identifier text and field data on one line, or,
skip and move to the next field, and so on.

Make sense?

The database can be SQL or .mdb (and/or sharepoint), prefer SQL/non
sharepoint.

Thanks
 
M

MD Websunlimited

Hi,

do while not rs.eof
for each oField in rs.fields
response.write oField.name & " = " & rs(oField.name) & "<br>"
next
rs.movenext
loop

Will read each record from the record set, enumerate the fields within that record set and display a line with field name and value.

HTH,

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
Download the Trial http://www.microsoft.com/frontpage/downloads/addin/launchupdate/download.asp
 
S

Stefan B Rusynko

That would write all records and fields in the record set - including empty fields
To exclude the empty fields in each record, it would need to be modified to:

do while not rs.eof
for each oField in rs.fields
If Not IsEmpty(rs(oField.name)) Then
response.write oField.name & " = " & rs(oField.name) & "<br>"
End If
next
rs.movenext
loop

Note:
If there are actually fields w/ Null values the above will not catch them
If the fields really have Null values the test would be
If Not IsNull(rs(oField.name)) Then





| Hi,
|
| do while not rs.eof
| for each oField in rs.fields
| response.write oField.name & " = " & rs(oField.name) & "<br>"
| next
| rs.movenext
| loop
|
| Will read each record from the record set, enumerate the fields within that record set and display a line with field name and
value.
|
| HTH,
|
| --
| Mike -- FrontPage MVP '97-'02
| J-Bots 2004 102 Components For FP
| http://www.websunlimited.com
| FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
| Download the Trial http://www.microsoft.com/frontpage/downloads/addin/launchupdate/download.asp
|
| > I've been away from ASP and ADO/DAO for several years and my books are in
| > storage in the next state ...
| >
| > I'm trying to remember some sort of recordset code so that I can not utilize
| > the webbot database/form tool. What I want to do is display all fields from
| > a record (about 25 fields, but on average, only 13 are used), but I want to
| > skip null fields and write out a continuous result to a page that ONLY has
| > field data and text identifiers for the fields WITH data, and not a bunch of
| > wasted real estate.
| >
| > Some how I need to fetch the field data, determine if it's null, then do an
| > If-then and place the field identifier text and field data on one line, or,
| > skip and move to the next field, and so on.
| >
| > Make sense?
| >
| > The database can be SQL or .mdb (and/or sharepoint), prefer SQL/non
| > sharepoint.
| >
| > Thanks
|
|
 
M

MD Websunlimited

Ooops, I forgot the conditional check being asked for.

Thanks for correcting it.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 102 Components For FP
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
 

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

Top