Sort ADO Database Twice

D

davidcoxmail

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
 
M

Mike Brind

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
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top