[postgis-users] re:Storing Waypoints in Postgres

Marc Angelo computrain at paradise.net.nz
Sun Apr 2 05:45:41 PDT 2006

Thank you very much for the responses - I am making some excellent progress. I am now connecting to Postgres via .Net ODBC connection and viewing data from a PostGIS table in PostGres. A corresponding record is automatically added into the geometry_columns table. Opening QGIS, I connect to Postgres and the waypoint is available to add. The only problem I have, is that once added, I can't see the waypoint in the viewing area - it shows up on the left hand side with a tick next to it......I'm thinking that somewhere a label needs to added with the data....do I do this in the Postgis table?

My next hurdle is to programmatically insert a waypoint into the PostGIS database. The following is the arbituary SQL statement I entered into PostGres which entered the waypoint into the waypoints table successfully.

 INSERT INTO waypoints(position, annotations)
         GeometryFromText('POINT(172.668265 -43.538778)', 4326),
         'A Random Waypoint'

......Now, the following is the VB.Net code I use to open the connection and insert the a waypoint into the PostGIS database

Private Sub InsertWaypoint()
        Dim ConnStr As String
        Dim SQLStr As String
        Dim dadapter As Microsoft.Data.Odbc.OdbcDataAdapter
        Dim OdbcDataReader As Microsoft.Data.Odbc.OdbcDataAdapter
        Dim connection As Microsoft.Data.Odbc.OdbcConnection
        Dim cmd As Microsoft.Data.Odbc.OdbcCommand

        ConnStr = "DRIVER={PostgreSQL};SERVER=;port=5432;DATABASE=gis2;UID=postgres;PWD=password;"
        connection = New Microsoft.Data.Odbc.OdbcConnection(ConnStr)

        SQLStr = "INSERT INTO waypoints(position, annotation "
        SQLStr = SQLStr & "VALUES( "
        SQLStr = SQLStr & "GeometryFromText('POINT(170.507263 -45.895897)', 4326),"
        SQLStr = SQLStr & "'Random Waypoint')"

        cmd = New Microsoft.Data.Odbc.OdbcCommand(SQLStr, connection)

            dadapter = New Microsoft.Data.Odbc.OdbcDataAdapter
            dadapter.InsertCommand = New Microsoft.Data.Odbc.OdbcCommand(SQLStr, connection)
            connection = Nothing
        Catch ex As Exception
            Exit Sub
        End Try
    End Sub

.....This works perfectly....well in so much as it does not error at any stage but no data appears in the table. I realise this is not a .Net forum but if anyone can see the problem please let me know. Nothing appears in the log to indicate a problem.....an error would be easier to deal with :) The connection part of the above code definitely works as I can use a Select statement to view records.

Any help would be greatly appreciated

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060403/c0a45845/attachment.html>

More information about the postgis-users mailing list