v0.9 and SqlServer2008

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Jan 18, 2010 at 6:08 PM

So first time that i am using sharpmap. Till now i managed to load successfully shapefiles to sharpmap in windows form app c# 3.5.

Next step is to load spatial data from my sql server 2008.

 

mapImage1.ActiveTool = SharpMap.Forms.MapImage.Tools.Pan;
            map = new Map(mapImage1.Size);
            string ConnStr = @"Server=GPAPADAK-PC\SQLEXPRESS2008;Database=GeocodingX;User ID=sa;Password=xxx;";
            SharpMap.Layers.VectorLayer laystr= new SharpMap.Layers.VectorLayer("STREETS");
            SharpMap.Data.Providers.SqlServer2008 sql2008 = new SharpMap.Data.Providers.SqlServer2008(ConnStr, "GeocodingX.dbo.tbl_GeoData", "GeoDataPoint", "GeoDataID");
           
            laystr.DataSource = sql2008;
            laystr.MaxVisible = 400;
            laystr.Style.Symbol = new Bitmap("col.png");
            
                  

            
            //map.Layers.Add(NomoiLayer);
            map.Layers.Add(laystr);
            map.ZoomToExtents();
            mapImage1.Map = map;


But the viewer is empty and no error is raised. Am i missing something. Maybe a reference?

I am using sharpmap 0.9 and referenced 3 dlls (sharpmap,extensions and UI)

 

Coordinator
Jan 19, 2010 at 9:13 AM

Hi xterm at a guess it is due to a mismatch betwwn the srid on the provider and the srid of the data in the db. Set the sql2008.Srid = whatever the db value is.

You can run:

select distinct geometryColumn.STSrid from geometrytable --Ideally this will only return 1 value

to find out if you are unsure  hth jd

Jan 19, 2010 at 9:28 AM

sql2008.SRID = 4;

still nothing. the same result.

i did sql2008.GetFeatureCount() to see if features are loaded and it actually returns all the features. But still blank map.

 

Jan 19, 2010 at 10:10 AM

Sorry it works just fine.

Apr 22, 2014 at 6:21 AM
same problem, help.
Coordinator
Apr 24, 2014 at 7:06 AM
Have you tried your connection?
Does sqlProvider.GetFeatureCount() return a reasonable value?
Does sqlProvider.GetExtents() return a reasonable value?
Does sqlProvider.GetGeometriesInView(sqlProvider.GetExtents()) return a collection of geometries?

Setting sqlProvider.MakeValid = true often helps.

If all that is true there must be an issue with your styling.