We help IT Professionals succeed at work.

Send GPS data to database

NCSO asked
Medium Priority
Last Modified: 2008-01-09
Hi Experts,

I am developing an application that displays the mobile user’s latitude/longitude, speed and direction; but I need to go a few steps further.  I need to find a way to send the latitude, latitude and the unit’s ID to a database.  I need the push to occur every 15-30 seconds “or” 1/8th of a mile, whichever occurs first.  What is the best way to make this happen?  I am new to VB and everything thus far is self taught, with some help from experts such as you.  Please be specific in your answers and I ask for your patience with me if I do not understand everything.

I am developing with Visual Studio 2005, language VB.
Watch Question

What is your target device?  A Windows Mobile cell phone?

Generally speaking, you won't be able to do what you envision.  Nearly all phones prohibit access to location information.  Furthermore, most phones do not have a full-fledged GPS receiver in them.  They have half a GPS receiver.  The other half is in some central office of the carrier (Verizon, Cingular, etc.).  Your phone just picks up the GPS signals and sends raw data over the network to the carrier who crunches the numbers to determine your location.  This is "Assisted GPS".

There is probably not enough raw data on the device itself to get a fix without the cooperation of the carrier.

You'll probably have to build your own device using a GPS receiver and a cell phone.  A good choice would be a Pocket PC phone and a Bluetooth GPS receiver.  You could then write some custom software for the phone to accomplish what you want.

Keep in mind that most devices don't have enough battery life to report a fix every 15 seconds.  They will go dead in less than a day.
Here's a Garmin Bluetooth receiver:

The PPC 6700 is an EVDO, Bluetooth phone that would be a good choice for this project:

You could alternatively use a laptop with a data card like this:


Thanks for your responses.  I apologize for not being more clear of the current configuration.  All the clients (laptop users) have a GPS antenna and receiver in the cars; and the current application displays the vehicles latitude, longitude and speed.  I need to be able to capture this data every 1/8th of a mile or every 30 seconds, whichever occurs first and store this GPS data in a SQL database table.  This process is required for us to complete an AVL (Automatic Vehicle Location) project here at the Sheriff's Office.  Thanks for you assistance.
So you don't need to transmit the location data over-the-air?  You just need to keep a log in a local SQL database on the laptop?

What you need is some custom software for your laptops that grabs GPS data from the serial port(?) and plops it into a database.  Such an application wouldn't be difficult to write.  I see that you already have Visual Basic.

Here's an article about SQL access from Visual Basic:


Here's a VB example for reading GPS data from an NMEA device:



PAQ refund please, I have developed the methodology necessary to accomplish my project needs.  My specific question was how to store the data stream to a database.

Sure. Post your solution and you get your points back - this is how EE works.
Because the solution above will work :) And unless you post another one, there is no reason not to give points


Per your request!
Dim conn As New System.Data.SqlClient.SqlConnection("Connection String Goes Here")
        Dim da As New System.Data.SqlClient.SqlDataAdapter("Select * from [table name]", conn)
        Dim ds As New System.Data.DataSet
        Dim cmd As New SqlCommand("insert into [table name](Latitude,Longitude,speedmph,fixstatus,unitid,username)values(@latitude,@longitude,@speedmph,@fixstatus,@unitid,@username)", conn)

            cmd.Parameters.Add(New SqlParameter("@longitude", SqlDbType.NVarChar = 12)).Value = Longitude.Text
            cmd.Parameters.Add(New SqlParameter("@latitude", SqlDbType.NVarChar = 12)).Value = Latitude.Text
            cmd.Parameters.Add(New SqlParameter("@speedmph", SqlDbType.NVarChar = 12)).Value = SpeedMPH.Text
            cmd.Parameters.Add(New SqlParameter("@fixstatus", SqlDbType.NVarChar = 12)).Value = FixStatus.Text
            cmd.Parameters.Add(New SqlParameter("@unitid", SqlDbType.NVarChar = 12)).Value = UnitID.Text
            cmd.Parameters.Add(New SqlParameter("@username", SqlDbType.NVarChar = 12)).Value = UserName.Text
        Catch ex As Exception
        End Try
PAQed with points refunded (500)

Community Support Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

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


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.