Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort recordset based on asp calculation result 1

Status
Not open for further replies.

ringadeal

Technical User
Jan 16, 2008
67
US
The following code displays the distance (in miles) based on an asp calculation on the webpage:

Code:
<%= int(GetDistance(istartLat, istartLong, (Recordset1.Fields.Item("LATITUDE")), (Recordset1.Fields.Item("LONGITUDE")), "M"))%>

How do I sort a recordset on the page based on the above calculation result?
 
The quickest thing is probalby to add a column to the table in your database, update the existing rows, and add triggers to keep the column synchronized for INSERT and UPDATE.

If you can't change the underlying database I suppose you could add a Field to the Recordset's Fields collection, spin through the recordset to populate the new field, and then re-sort.
 
How is the second suggestion accomlished as I am a novice at asp?
 
What database are you using? I have some code for Microsoft SQL server that will calculate the distance (in miles) for 2 points (latitude and longitude in WGS84 coordinate system).

If you had this function in the database, then you could calculate the distance there, and use it to sort the recordset.

Let me know if you're interested.



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Maybe you could convert the function to Access so that you can use it anyway. Unfortunately, I won't be able to help you too much, except for showing the SQL Server function. It's here:




-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top