zip code search

S

Steve

Hi-
I'm looking to make an asp.net application that will allow site visitors to
enter their zip and find the closest dealer in our database. Funny thing
is... I have NO idea how this is done! I figure there must be a way to
query the DB for zips that are in the same state as the seach zip, then
enumerate over all of those and calculate the distance from each one storing
the shortest ones. But how, is there a service you need to subscribe to?
Anyone have some pointers?
 
K

Karl Seguin

Steve:
Normally what you can do is measre the distance between two geographical
points (latitude/longitude). This is pure mathematics. You must map your
zip code to lat/long coordinates. You can find databases for this online.
One such vendor is http://www.zipcodeworld.com/ (they also have the source
code for determining the distance between two coordinates online:
http://www.zipcodeworld.com/samples/distance.cs.html but it isn't free to
use, I don't think).

There are plenty of open source projects written in a veriaty of languages.
The only C# one I was able to quickly find was:
http://www.codeproject.com/csharp/ZipCodeUtil.asp

Karl



--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
J

jhcorey

What you have to do is find a function that you can use in your sql
query to calculate distance -- if you google the sqlserver.programming
group I'm sure you'll find one -- I've done this but I don't have it
handy.
Then your query looks something like this:

select myCalculation(lat,long,dealerLat,dealerLong) as Distance,
dealerName from myTable
order by Distance

(obviously a prerequisite would be getting the lat/long for the zips).
 
S

Steve

right, that is proving to be the missing piece that I was looking for, the
lat/long data for the zips. MS has mappoint that they sell as a web
service, but I was hoping there would be a free service. I will look at the
links that Karl posted.

Thanks for the help guys!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top