borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincani

AndreaVB Home | News Home | Forum Home | Downloads | Register | Search | PM | Profile

Previous Topic (Geting the Character on the list Menu)Next Topic (rum time error 3704) New Topic Post Reply
AndreaVB OnLine : Database : Question about populating MSFlexGrid
Poster Resource
Navaidstech
Level: Trainee

Registered: 25-11-2008
Posts: 1
icon Question about populating MSFlexGrid

Hi all... I'm just getting into database programming. Find it much easier than accessing large random data files. However I have a question about SQL query that I can't get to do what I want it to do.
Let me simplify it by assuming a database with three fields - City Name, Longitude, Latitude.
I'm trying to create a query that will populate an MSFlexGrid control with only those cities that start with a certain letter AND are a certain distance from a given location.
I realize that I could introduce an extra field in the database that will contain the actual distances to these cities and be done with it but the problem here is that the central location is not fixed (ie. a moving car). So in essence I have to extract the lat/lon from the database, calculate the distance, then apply the city name filter and then populate the MSFlexGrid...

I was playing around with "Select * FROM xxx WHERE..." type query and it almost does what I want it to do, but can I apply an externally calculated distance filter to it?

Any help would be greatly appreciated.

thanks


____________________________
Alex

25-11-2008 at 02:33 PM
View Profile Send Email to User Show All Posts Visit Homepage | Add Comment
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 606
icon Re: Question about populating MSFlexGrid

Hi,
Presumable you have the Longitude and Latitude of the Location from which you want to calculate the distance. So to return cities within a fixed distance of that point you could search for a fixed range of Longitude and Latitude :-
WHERE ((Longitude Between x And y) AND (Latitude Between a And b))
Just one point on the naming of fields in a database - it's best not to include spaces as you will need to remember to enclose the field name in square brackets for a query, [City Name] so change it to "CityName" or  "City_Name"


[Edited by GeoffS on 27-11-2008 at 08:12 AM GMT]

____________________________
multi-tasking - the ability to hang more than one app. at the same time.

27-11-2008 at 08:08 AM
View Profile Send Email to User Show All Posts | Add Comment
AndreaVB OnLine : Database : Question about populating MSFlexGrid
Previous Topic (Geting the Character on the list Menu)Next Topic (rum time error 3704)New Topic Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder