Hello,
I’ve been having issues with SqlServerFeatureLayer issues for a long time in my code, but recently things start to break down. I hope it’s my novice programming skills and that you are able to help me.
This is my peace of code which has been working for a long time, but now I updated to the latest version of Thinkgeo:
Thinkgeo.UI.WPF 14.2.1
Thinkgeo.Core 14.2.1
Thinkgeo.Dependency.SqlClient 12.4.0
Thinkgeo.SqlServer 12.2.22
Dim MSSQLLayer As New SqlServerFeatureLayer(_SQLstringAsfalt, "vwHVHCalc_Asfalt_Nietgereed", "id", 31370)
MSSQLLayer.FeatureSource.ProjectionConverter = New ProjectionConverter(proj28992, 3857)
'Add an overlay to the map
OVL = mapView2.AddContentOverlay(sOverlayname)
Dim LayerFeatures As New Collection(Of Feature)
If Not MSSQLLayer.IsOpen Then MSSQLLayer.Open()
LayerFeatures = MSSQLLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns)
Dim LayerColumns As Collection(Of FeatureSourceColumn) = MSSQLLayer.FeatureSource.GetColumns()
This now results in exception ‘Datareader.GetFieldType(2) has returned null-value’ when executing GetAllFeatures and GetColumns().
- When I change ReturningColumnsType to .NoColumns I get all the features but without other data off course.
- I checked the query… there are NO null values in the result and even if there were that should not crash the code.
Any idea what might be causing this? I’m a novice programmer and have no clues (after days of searching).
Other problem is the SqlServer version. I still use 12.2.22 because that is for me the latest working version. I’ve skipped updating this, because this versions kept working, but I don’t see what’s the problem.
After updating to the newest version I get this error when the MSSQLLayer.Open() function is executing:
‘The command already has an open DataReader associated with it that must be closed first.’ (translated from Dutch).
When the code continues up-to GetAllFeatures this is the message I get:
‘The FeatureSource is not open. Please call the Open method before calling this method.’
When I do that by adding mssqllayer.featuresource.open before the getallfeatures I get the same message about Datareader as earlier.
Can you help me out?
Kind regards,
Guido van den Boom