Sort ADO Database Twice

Discussion in 'ASP General' started by davidcoxmail@gmail.com, Jun 20, 2006.

  1. Guest

    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
    , Jun 20, 2006
    #1
    1. Advertising

  2. Mike Brind Guest

    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
    Mike Brind, Jun 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nita
    Replies:
    1
    Views:
    869
    Saravana
    Nov 20, 2004
  2. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    454
    Kevin Spencer
    Dec 17, 2004
  3. Replies:
    0
    Views:
    1,311
  4. JerryJ
    Replies:
    11
    Views:
    1,402
    Dave Moore
    Apr 28, 2004
  5. Navin
    Replies:
    1
    Views:
    690
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page