troubleshooting Question

Prevent Duplicates in ASP Array

Avatar of Bob Schneider
Bob SchneiderFlag for United States of America asked on
Microsoft SQL ServerASPSQL
7 Comments5 Solutions150 ViewsLast Modified:
I want to use GetRows() in this query but I want to ensure that no meet included multiple times.  The goal is to speed the query up.  This "works" but is way slow and inefficient.  Thanks in advance!

    Set rs = Server.CreateObject("ADODB.Recordset")
    sql = "SELECT m.MeetsID, m.MeetName, m.MeetDate, m.MeetSite FROM Meets m INNER JOIN MeetTeams mt ON m.MeetsID = mt.MeetsID INNER JOIN Roster r ON "
    sql = sql & "mt.TeamsID = r.TeamsID INNER JOIN IndRslts ir ON ir.MeetsID = mt.MeetsID WHERE ir.RosterID IN (" & sSelectQS & ") AND ir.Place > 0 "
    sql = sql & "AND (m.MeetDate >= '" & dBegDate & "' AND m.MeetDate <= '" & dEndDate & "') AND Sport = '" & sSport & "' ORDER BY m.MeetSite DESC"
    rs.Open sql, conn2, 1, 2
    Do While Not rs.EOF
        If x = 0 Then
            AllMeets(0, x) = rs(0).Value
            AllMeets(1, x) = Replace(rs(1).Value, "''", "'") & " (" & Month(rs(2).Value) & "/" & Year(rs(2).Value) & ")"
            AllMeets(2, x) = rs(2).Value
            AllMeets(3, x) = Replace(rs(3).Value, "''", "'")
            x = x + 1
            ReDim Preserve AllMeets(3, x)
        Else
            For z = 0 To UBound(AllMeets, 2) - 1
                If CLng(rs(0).Value) = CLng(AllMeets(0, z)) Then
                    Exit For
                Else
                    If z = UBound(AllMeets, 2) - 1 Then
                        AllMeets(0, x) = rs(0).Value
                        AllMeets(1, x) = Replace(rs(1).Value, "''", "'") & " (" & Month(rs(2).Value) & "/" & Year(rs(2).Value) & ")"
                        AllMeets(2, x) = rs(2).Value
                        AllMeets(3, x) = Replace(rs(3).Value, "''", "'")
                        x = x + 1
                        ReDim Preserve AllMeets(3, x)
                    End If
                End If
            Next
        End If
        rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 5 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros