IIS ASP - Sort ADO Database Twice

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > June 2006 > Sort ADO Database Twice





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Sort ADO Database Twice
davidcoxmail@gmail.com

2006-06-20, 7:24 pm

Got a simple, noob problem:

I need to call a display an MS Access db using ASP; I need to display
it by Organization and District Number (sort it twice).

Example:

Organization A, District 1
Name 1
Name 2...
Organization B, District 2
Name 3
Name 4...

I've tried a nested Loop statement that looks like this:

do until rs.EOF

Name=rs.fields("Name")
District=rs.fields("District")

IF District=rs.fields("District") then
IF OfficeSought=rs.fields("Name") then

Do while OfficeSought=rs.fields("OfficeSought")

<<code for displaying actual
records goes here>>

rs.MoveNext
loop
End IF
End IF


rs.MoveNext
loop

Instead of returning the data the way I want it to, it tends to only
get it "half-right" (i.e. not displaying all the records in my db, not
properly grouping all of them by District, etc.)

What changes would you recommend trying? Any help would be very much
appreciated (and please use noob-speak, as I am relatively new to the
world of database-driven web apps).

Thanks!

Cash

Mike Brind

2006-06-20, 7:24 pm


davidcoxmail@gmail.com wrote:
> Got a simple, noob problem:
>
> I need to call a display an MS Access db using ASP; I need to display
> it by Organization and District Number (sort it twice).
>
> Example:
>
> Organization A, District 1
> Name 1
> Name 2...
> Organization B, District 2
> Name 3
> Name 4...
>
> I've tried a nested Loop statement that looks like this:
>
> do until rs.EOF
>
> Name=rs.fields("Name")
> District=rs.fields("District")
>
> IF District=rs.fields("District") then
> IF OfficeSought=rs.fields("Name") then
>
> Do while OfficeSought=rs.fields("OfficeSought")
>
> <<code for displaying actual
> records goes here>>
>
> rs.MoveNext
> loop
> End IF
> End IF
>
>
> rs.MoveNext
> loop
>
> Instead of returning the data the way I want it to, it tends to only
> get it "half-right" (i.e. not displaying all the records in my db, not
> properly grouping all of them by District, etc.)
>
> What changes would you recommend trying? Any help would be very much
> appreciated (and please use noob-speak, as I am relatively new to the
> world of database-driven web apps).
>
> Thanks!
>
> Cash


You need to do the sorting in the SQL call to the database.

SELECT <fields> FROM <table> ORDER BY Organisation, District. Then I
recommend you have a look at this article for ideas on how to display
them:

http://www.aspfaq.com/show.asp?id=2241

--
Mike Brind

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com