Using socket to establish database connection

Apr 3, 2011 at 8:29 PM
Hi
I am attempting to use a socket to establish the database connection for my SharpMap.
The information from the socket gets distributed properly, the form is renewed through a “new frmGraphics2” - but the PostGIS connection does not seem to be established. The connectionString as read through the MessageBox is correct.
Following is the portion of code that I believe to be pertinent.
Any thoughts on what I need to do??
Bob
public frmGraphics2()
{
this._sharpMap = new Map(base.Size);
this._Activetool = SharpMap.Forms.MapImage.Tools.None;
base.MouseMove += new MouseEventHandler(this.picMap_MouseMove);
base.MouseUp += new MouseEventHandler(this.picMap_MouseUp);
base.MouseDown += new MouseEventHandler(this.picMap_MouseDown);
base.MouseClick += new MouseEventHandler(this.picMap_MouseClick); //Right Mouse Click
base.MouseWheel += new MouseEventHandler(this.MapImage_Wheel);
this.DoubleBuffered = true;
{
InitializeComponent();
string connectionString = ("Server=192.168.1.102;Port=5432;User ID=postgres;Password=*****;" + GlobalClass.connectDB);
//--> Initialize the Map
_sharpMap = new Map(new Size(1700, 1000)) { BackColor = Color.WhiteSmoke };
PostGIS provider = new PostGIS(connectionString, "p_id.image", "the_geom", "public"); //create a new provider
MessageBox.Show("Connection2 " + connectionString); //for troubleshooting
VectorLayer myLayer = new VectorLayer("My Layer");
myLayer.Style = new VectorStyle
{
Line =
{
Width = (1.0F / 4.0F),
Color = Color.Black,
EndCap = LineCap.Round,
},
EnableOutline = false
};
Coordinator
Apr 3, 2011 at 8:44 PM

Hi,

You also need to set the DataSource property of the VectorLayer to your connection

myLayer.DataSource = provider;

 

Apr 3, 2011 at 10:39 PM
Hi petlof
That code is present I just didn’t send it.
I guess more info is needed.
I have been using filewatcher to send the connection info. That works well, but I want the socket connection so that I don’t leave files laying around.
So on compile using filewatcher there is no problem with the DB connection.
Using the socket, when I compile the variable is not yet there - so the DB connection isn’t complete - so it can’t be made.
When the socket connects and passes the variable and I trigger a new frmGraphics2, the DB connection is still not made although the DB connection string is complete and shows as being correct.
To me (novice) it seems as if the .net side is not refreshing with the new (and complete) connection string when I rerun frmGraphics.
I can’t find anything in my searches that help me.
Bob
From: [email removed]
Sent: Sunday, April 03, 2011 12:44 PM
To: [email removed]
Subject: Re: Using socket to establish database connection [SharpMap:252330]

From: petlof

Hi,

You also need to set the DataSource property of the VectorLayer to your connection

myLayer.DataSource = provider;