p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

proasp_codeclinic thread: Sample code to generically report sorted SQL results into nested -html tables????

Message #1 by "Gould, Trevor (AB07)" <Trevor.Gould@h...> on Wed, 9 Aug 2000 12:28:29 -0700
Has anyone ever done this or seen sample code for it somewhere??

I want a routine that will take a recordset and report it in nested tables.
For example, lets say I wanted a new report, so I would set the SQL and the
grouping fields, the SQL would result in the fields Country, State, City,
Population, Area, etc., ordered (not grouped in the SQL) by the specified
group by fields.
If I had specified that I would like to group by Country and State, I would
then like to see something like:
        City            Population    Area
        Calgary        900,000        25
        Edmonton    800,230        33
        City            Population    Area
        blah            blah             blah
        City            Population    Area
        Los Angeles
And this would be all in nested tables, a new table for every level of
Now this is pretty darn standard reporting in the real world.  And for the
life of me I can't figure out the logic on how to get this to work (I want
it to recognize a change in any level at all times, so on each new record,
perhaps the city might remain the same but the country could possibly change
so I would want to drop back down to level 1).  I've worked on this for
quite a bit and I can't get it, it must be programmers block or something.
The beauty of code like this is, if a new report is requested by a user, you
could have it done in just a few minutes by simply defining the SQL and
Group By fields in a table, whereas reports now (for me at least) take quite
a while and usually look ugly when they're done.
So I was wondering if anyone has ever seen a code sample anywhere for this?
I've checked all my regular places (dejanews, asptoday, asplists, powerasp,
etc) but can find no reference to this technique whatsoever.
Thanks very much,
Trevor Gould

  Return to Index