Recently I downloaded the latest Development Branch dlls in order to take advantage of some bug fixes. The bug fixes were fine but were verified in a sample project, not our main application. When these new dlls were referenced in our full application we noticed that SQL Server layers were not visible. This was in version 6.0.331.0. I rolled back to version 6.0.326.0 and the SQL Server layers still did not appear. Finally I rolled back to version 6.0.324.0 and the SQL Server layers are now appearing correctly.
It might be a bug there but we did a simple test and seem works fine with the latest version, so we can guess there are some different things between us. We did do some modification on Srid after version 6.0.324.0. So, we wonder what’s your projection in your Sql Server? Did you assign some value to property “Srid” on MSSql2008FeatureLayer?
Yes, we always assign an Srid when we create MsSql2008FeatureLayers. Here is the code:
Private Sub LoadSQLSpatialLayer() Dim oOverlay As LayerOverlay Dim sConnect As String = "Data Source=STEVEM6500\WOOFPUPPY;Initial Catalog=BaseData;Integrated Security=True;User ID=;Password=" Dim oAreaStyle As AreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.SimpleColors.Blue, 1, LineDashStyle.Solid, 0, 0)
moSQLLayer = New CustomSqlLayer(sConnect, "County", "CountyID", 102003)
Dim oMap As WinformsMap = WinformsMap1
oOverlay = New LayerOverlay oMap.Overlays.Add("County", oOverlay)
Actually we had fixed a bug about srid once, and it is that cannot get any shapes (like the situation as yours) when using a specified srid (not 102003) on SqlServerTypes, but when set the srid to 0 (which means don’t use any projection), the correct result can be gotten. I wonder there is an issue in SqlServerTypes. Now we have back this change to same with 6.0.324.0, you can check it on the latest building version of 6.0.337.0.
With version 6.0.337.0 my Sql Server layers are drawing again. Did I understand you correctly to say Sql Server layers will not draw if created with srid = 0? In the Sql Server world 0 is acceptable.
In our work we use many custom coordinate systems that are not defined with any standard Srid. When I have tested these in the past they worked fine when creating Sql Server layers using 0 as the srid. We also define our own in-house srids. In my testing with 6.0.337.0 I find that now the Sql Server layers will not draw if srid=0 but also they will not draw if srid is some other number <> 0. This is very bad for us, does it have to be that way?
The 6.0.337.0 is the same as the old dlls, currently we don’t know the reason, with some coordinates system it cannot be displayed by srid 0, while others can be, so I think we need to provide the right srid of the geometries/geography to Sql Server and it can return the right results.
I had a similar discussion on this forum back in 2010 and I thought things were pretty much settled. At that time it was made clear to me that using an srid of 0 was acceptable when creating a MsSql2008FeatureLayer. And while we may not use 0, we will have to use something other than a standard srid because our custom coordinate systems do not have standard srids.
I think I have figured out my issue, thanks for your patience.
I did some further experimentation with one of our custom coordinate systems and here's what I discovered. You can use 0 or any other number you like for the srid so long as you specified that srid when you created the spatial table in Sql Server. I picked an srid of 461 and added features from a shape file that uses our custom coordinate system. Then when I create the MsSqlServer2008FeatureLayer I pass 461 and the srid and everything works fine.