Sql server 2008

Topics: Data Access, WinForms Controls
Dec 22, 2011 at 1:43 PM

I am new at SharpMap

I have a spatial data in sql server 2008 uploaded by Esayloder in Mapinfo

Geometry col is SP_GEOMETRY.

i am trying to draw map with :

 Using dr As New SharpMap.Data.Providers.SqlServer2008(constr, table, pk, SharpMap.Data.Providers.SqlServerSpatialObjectType.Geometry)
            dr.GeometryColumn = "SP_GEOMETRY"
            dr.ValidateGeometries = True

            Dim map As New SharpMap.Map(New Size(MapBox1.Width, MapBox1.Height))
            map.Size = New System.Drawing.Size(300, 400)
            map.BackColor = Color.Red

            Dim layer_il As New SharpMap.Layers.VectorLayer("IL")
            layer_il.DataSource = dr
            '    layer_il.MaxVisible = 40000
            layer_il.Style.Fill = Brushes.Green
            layer_il.Style.Outline = Pens.Black
            layer_il.Style.Fill = Brushes.Black

            layer_il.Style.EnableOutline = True

            map.BackColor = Color.LightBlue
            MapBox1.Map = map
        End Using


But , there is nothing appers.

Is there any way to to this ?

Dec 22, 2011 at 2:37 PM

Does MapInfo store its geometry tables in the default schema (dbo)? If not, you may need to move the table to the default schema.

Hth FObermaier.

Dec 22, 2011 at 2:44 PM

tables are in the default schema. also , ssmse shows spatial data

Oct 21, 2013 at 10:40 AM
Why do they need to be in the default schema?

In the source code the schema is stripped out. Why is this? what is wrong with leaving it in if it is specified as part of the table name?
Oct 21, 2013 at 10:46 AM
anyway I changed the code to this

/// <summary>
   /// Data table name   
   /// </summary>   
   public string Table   
           if (!string.IsNullOrEmpty(TableSchema))
               return TableSchema + "." + _table;

           return _table;
       set { _table = value; }   
So it checks if the schema exists then if it does it appends it to the tablename
Oct 21, 2013 at 3:31 PM
If you do that you need to make sure that a possible schema component of the tablename is split off in the setter .
Iirc the postgis provider behaves differently. We should keep them similar
Oct 21, 2013 at 4:34 PM
It is split in the setter by default.

I'll have a look at how the postgis implementation handles it.

I'm just looking at creating a sqlserver2012 provider now as 2012 handles geographies a bit differently to 2008. It'll basically be a modifed version of the 2008 provider.

Although it would probably be better to have a single sqlserver provider that automatically switched depending on the database type.
Oct 21, 2013 at 8:28 PM
If you address the SqlServer provider, you may want to consider using the NTS.IO libraries for reading and writing.
It perfroms better than converting having SqlServer convert it to WKB and then NTS parse the WKB.

I must admit, I have not tested them with SqlServer 2012
Oct 22, 2013 at 11:25 AM
I may well look at using entity framework code first for my work, so i may end up writing an entity framework provider that uses the built in ef query functions to store and retreive dbGeometry objects. Then they will be cast directly into geoapi i geometry instances using toWKB or something. This is all still very much in prototype stages!