We help IT Professionals succeed at work.

Prevent Duplicates in ASP Array

146 Views
Last Modified: 2017-12-10
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

Open in new window

Comment
Watch Question

Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Bob SchneiderCo-Owner

Author

Commented:
This query culls all Nordic ski meets participated in by a group of skiers over a period of time.  They have not all competed in all meets during this period of time.  I want to get all meet info (m.MeetsID, m.MeetName, m.MeetDate, m.MeetSite) for every meet that at least one of these skiers participated in but I don't want the meet listed multiple times just because multiple skiers skied in the same meet.
Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Database Expert
Awarded 2016
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Bob SchneiderCo-Owner

Author

Commented:
Thank you.  What is CTE1 and what do you mean "my final query"?  The actual sql query I am currently using?
Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Scott FellDeveloper
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.