<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1528" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Managed to finally get data moving from my VB.Net 
into a PostGIS database last night&nbsp;:)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I turned to npgsql which did an excellent job (and 
used less code) than other types of connectors. Below is some simple code I got 
working to insert a waypoint into a PostGIS database</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT 
size=2></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT size=2>Imports System<BR>Imports 
System.Data<BR>Imports Npgsql</FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial>Private Sub 
Insert_Waypoints()</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dim 
conn As Npgsql.NpgsqlConnection<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Dim command As 
Npgsql.NpgsqlCommand<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim SQLStr As 
String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim rowsaffected As 
Int32</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;</DIV>
<DIV>'these next two lines log events tha happen with npgsql - only required if 
things turn to custard<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
NpgsqlEventLog.Level = 
LogLevel.Debug<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
NpgsqlEventLog.LogName = "NpgsqlTests.Log"</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>'Connection string - just replace the details with 
yours</FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
conn = New NpgsqlConnection("SERVER=10.10.10.9;port=5432;User 
Id=postgres;Password=password;Database=gis2;")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
conn.Open()</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>'I was trying to keep it tidy so built the SQL 
statement bit by bit</FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
SQLStr = "INSERT INTO waypoints(position, 
annotation)"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLStr = SQLStr &amp; 
"VALUES("<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLStr = SQLStr &amp; 
"GeometryFromText('POINT(172.668265 -43.538778)', 
4326),"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLStr = SQLStr &amp; 
"'New Waypoint'"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLStr = SQLStr 
&amp; ")"</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
command = New NpgsqlCommand(SQLStr, conn)</FONT></FONT></DIV>
<DIV><FONT size=2><FONT 
face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rowsaffected = 
command.ExecuteNonQuery()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch ex 
As 
Exception<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
MsgBox(Prompt:=ex.ToString)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End 
Try</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
conn.Close()</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial>End Sub</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial>...npgsql actually has some great examples 
included in it's docs but for us VBer's we need to translate it from C#. I am 
unsure as to why it didn't work before.....I haven't changed the SQL statement 
so must of been my code.</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial>Cheers</FONT></DIV></FONT></BODY></HTML>