Development of map using SQL as points

Topics: General Topics
Aug 3, 2006 at 8:28 AM
Hi there guys

I just want to know what is needed to intergrate SQL and Sharpmap..any help please
Aug 3, 2006 at 8:44 AM
Ehm a SQL database would be my guess. Could you by any chance be more specific?
Also check out:
Aug 3, 2006 at 8:56 AM
I have a SQL database with names and addresses. I`m trying to query the database the databases` X and Y fields to display it on the map....The map is Suburb level...So with the X and Y fields I want to display the address point...How do I actually set everything up to display the data correctly....Do I need a shapefile of Suburbs and Addresses (for point)and how do I get my to display specified points...
Hope this is more specific

Thanx in advance
Aug 3, 2006 at 9:37 AM
You can use the OleDbPoint provider for this.

Just make sure your X and Y columns are doubles, and that you have a unique ID column as an integer datatype (this is important or you will receive a cast-exception!).

You then bind the OleDbPoint Provider as a datasource to a VectorLayer.
Aug 3, 2006 at 11:42 AM
Which vectorlayer....The one where you allow the display of points...Im experiencing a problem with the the ZoomExtents method...finaly im displaying the points from the sql database... but everything is conjested...and thats when i set Zoom = 360...Any idea to get round that please...
Aug 3, 2006 at 11:56 AM
What do you mean by "everything is conjested" ? And does that happen when you use ZoomToExtents() or when you set zoom to 360? Please be a bit more specific.

This is how I would create a map from a point database:

SharpMap.Map myMap = new SharpMap.Map(new System.Drawing.Size(500,250));
SharpMap.Layers.VectorLayer layAddresses = new SharpMap.Layers.VectorLayer("Addresses ");
layAddresses.DataSource = new SharpMap.Providers.OleDbPoint(ConnentionString, "MyTableName", "IDcolumn", "X", "Y");

Image img = myMap.GetMap();
Aug 3, 2006 at 1:00 PM
When I use map.ZoomToExtent I get an exception.."Specified cast not valid"...and when I zoom to 360 the point are displayed but they are overlapping each other...almost looks like you viewing one point...Does that help.....Im not using the oledbpoint provider im using the mssql provider...which one do you think works best...
Thanks again
Aug 3, 2006 at 1:13 PM
I tried the oledbpoint provider and its working quite fine...Does the DefinitionQuery method filter the sql database and will thos points only be displayed on the map....
Aug 3, 2006 at 1:30 PM
You can't use the MsSql provider. It is meant for something else (it requires min/max columns, binary WKB columns etc), but supports much more than just points. If you want OleDb provider to use the MsSql namespace, just grab the source for the provider and replace 'OleDb' with 'MsSql' everywhere. You can just add this to your application as a new class. This could probably give you a small increase in speed.

The definitionquery is for filtering data. Just put in anything that you would put in a SQL WHERE clause. Ex. "ROADNAME='New York Street' AND HOUSENO>200"
Aug 3, 2006 at 2:15 PM
The the oledbpoint doesnt need the WKB binary field...How does it know how to dispaly the point...Do i have to create a vectorlayer where the address points are on...and what if you use the definitionquery method to display specified point give by the result of the creating another vectorlayer to display the result...hope this is not to confusing...
Aug 3, 2006 at 2:40 PM
When I ask a vectorlayer to execute the the DefinitionQuery method...I get this exception "DataSource property not set on layer 'selection'" and I definitely set the DataSource....Any help
Aug 3, 2006 at 3:02 PM
Ehm asking a VectorLayer to execute the definition query?!??! A VectorLayer doesn't have a DefinitionQuery property.

Could you give us some code showing what you are doing? We don't guess very well ;-)
Aug 4, 2006 at 11:19 AM
Im adding a suburb and Postal code pint layer....the last layer is a to select specified point/s...What is the NetTopologysuitr used for
Oct 19, 2006 at 9:43 AM

I need also this functionality, but I have a problem with the connection string.

Can you post your sample code?


Oct 19, 2006 at 4:31 PM
A connection string is database-specific. For example, an SQL Server connection string is:

Data Source=(local);Initial Catalog=GISData;Integrated Security=SSPI

and a connection string for a Sybase database is:

Oct 20, 2006 at 4:24 PM :-)