Send GPS data to database

Posted on 2006-03-28
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.
Question by:NCSO
    LVL 6

    Expert Comment

    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.
    LVL 6

    Expert Comment

    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:


    Author Comment

    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.
    LVL 6

    Expert Comment

    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:


    Author Comment

    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.
    LVL 20

    Expert Comment

    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

    Author Comment

    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

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    gps boundary reader 7 424
    Google Maps Frustration 7 418
    SQL - Select and Replace Syntax 9 131
    GPS with route remote planning 1 82
    I feel like more and more people want to know how to programmatically convert addresses into geospatial locations. So in this article, I will show you how you can do it with Bing Maps. I'm going to use PowerShell, which is a nice scripting language,…
    Introduction This article is designed to assist GIS (Geographic Information System) and GPS (Global Positioning System) developers using ESRI ArcGIS and other spatial information management systems.   For the uninitiated the concept of projectio…
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now