[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.0

need help ordering search results, for zip code search

Asked by pshudgins in VB Script, SQL Query Syntax

Tags: asp, all

My code is below... works well, here's the results:

http://www.daikinac.com/commercial/locator_submit_test.asp

But, I need help ORDERING the zip codes by DISTANCE... and I'm really struggling. The problem is that "Distance" is declared AFTER the SQL for the recordset.  I also need to round the mileage up, to only two decimal points.

The code so far is below, and ideas would be much appreciated.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Option Explicit

<!--#include file="DistanceAssistant.inc"-->
<!--#include file="RadiusAssistant.inc"-->

Dim _
    ZIPCode, _
    Miles, _
 _
    Latitude, _
    Longitude, _
 _
    ZIPExists, _
 _
    DatabaseConnection, _
    DatabaseQuery

ZIPCode = "10001"
Miles = 5
Latitude = 0
Longitude = 0
ZIPExists = False
DatabaseConnection = "xxxxxxxx"

Dim dbConn: Set dbConn = CreateObject("ADODB.Connection")
dbConn.Open DatabaseConnection

DatabaseQuery = "SELECT Latitude, Longitude FROM PostalCodes WHERE PostalCode = '" & ZIPCode & "'"

Dim rsZIPCodes: Set rsZIPCodes = CreateObject("ADODB.Recordset")
rsZIPCodes.Open DatabaseQuery, dbConn

If rsZIPCodes.EOF Then
    'ZIP Code does not exist - report to user...
Else
    'ZIP Code does exist...get lat/long
    Latitude = rsZIPCodes("Latitude")
    Longitude = rsZIPCodes("Longitude")
    ZIPExists = True
End If

rsZIPCodes.Close
Set rsZIPCodes = Nothing

If ZIPExists Then
    Dim zcdRadius: Set zcdRadius = CreateObject("ZIPCodeDownload.RadiusAssistant")
    zcdRadius.Calculate Latitude, Longitude, Miles
   
    Dim _
        MaxLatitude, _
        MaxLongitude, _
        MinLatitude, _
        MinLongitude
       
    MaxLongitude = zcdRadius.MaxLongitude
    MinLongitude = zcdRadius.MinLongitude
    MaxLatitude = zcdRadius.MaxLatitude
    MinLatitude = zcdRadius.MinLatitude
   
    Set zcdRadius = Nothing
   
    DatabaseQuery = "" _
        & " SELECT * FROM PostalCodes inner join dna_dealers on postalcodes.postalcode like dna_dealers.postalcode WHERE" _
        & "     Latitude >= " & MinLatitude _
        & "     AND Latitude <=" & MaxLatitude _
        & "     AND Longitude >= " & MinLongitude _
        & "     AND Longitude <= " & MaxLongitude _
        & "     AND CityType = 'D'"
       
    Dim zcdDistance: Set zcdDistance = CreateObject("ZIPCodeDownload.DistanceAssistant")
       
    Set rsZIPCodes = CreateObject("ADODB.Recordset")
    rsZIPCodes.Open DatabaseQuery, dbConn


    While Not rsZIPCodes.EOF
       
        Dim _
            Latitude2, _
            Longitude2, _
            Distance

        Latitude2 = rsZIPCodes("Latitude")
        Longitude2 = rsZIPCodes("Longitude")
        Distance = zcdDistance.Distance(Latitude, Longitude, Latitude2, Longitude2)

        If Distance <= Miles Then
                  'this ZIP Code is within Miles of ZIPCode
            'display appropriate information to the user...
                  Dim strCity : strCity = rsZIPCodes("City")
                  Dim strAccount: strAccount = rsZIPCodes("Account")
                  Response.Write(strCity & " - " & strAccount & " - " & Distance & "<BR>")
        End If
        rsZIPCodes.MoveNext
    Wend
   
    rsZIPCodes.Close
    Set rsZIPCodes = Nothing

End If

dbConn.Close
Set dbConn = Nothing
%>
[+][-]08/25/08 12:40 PM, ID: 22308478Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: VB Script, SQL Query Syntax
Tags: asp, all
Sign Up Now!
Solution Provided By: DanielWilson
Participating Experts: 1
Solution Grade: A
 
[+][-]08/25/08 10:24 AM, ID: 22307325Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 10:31 AM, ID: 22307377Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 10:54 AM, ID: 22307555Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 11:06 AM, ID: 22307658Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 11:20 AM, ID: 22307768Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 11:26 AM, ID: 22307815Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 11:37 AM, ID: 22307904Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 11:47 AM, ID: 22307988Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 11:56 AM, ID: 22308072Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 12:00 PM, ID: 22308108Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 12:13 PM, ID: 22308214Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 12:13 PM, ID: 22308216Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 12:17 PM, ID: 22308240Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 12:17 PM, ID: 22308246Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 12:22 PM, ID: 22308291Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 12:28 PM, ID: 22308338Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 12:29 PM, ID: 22308345Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/08 12:48 PM, ID: 22308553Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/08 12:54 PM, ID: 22308610Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/27/08 07:11 AM, ID: 22324926Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628