ThinkGeo.com    |     Documentation    |     Premium Support

Sql Server - Error On Open

Hello,
I have a table in SQL-Server. This table have a Column with the name “open”.
When I try to open the featuresource with (SqlServerFeatureSource.Open()) on error occurs “SqlException: Incorrect syntax near the keyword ‘open’.”

Regards Torsten

Hi Torsten,

Are you able to post a few lines of your code to make sure I look at the right API? Also, are you doing anything with the ‘open’ column programmatically? Or is it failing just based on this table containing a column named ‘open’?

Thanks,
John

Hi John,
it’s a WPF-App. There a only some lines of code:

SqlServerFeatureSource msSqlFeatureSource = new SqlServerFeatureSource();
msSqlFeatureSource.ConnectionString = cstr.Connectionstring;
msSqlFeatureSource.CustomGeometryColumnName = settings.GeoColumnName;
msSqlFeatureSource.FeatureIdColumn = settings.IdColumnName;
msSqlFeatureSource.TableName = settings.TableName;
msSqlFeatureSource.SchemaName = cstr.Schema;
msSqlFeatureSource.Srid = Srid;
msSqlFeatureSource.Open();
-- here the error occurs.

If i rename to columname, e.g. “op” instead “open”, there are no errors.

Regards Torsten

Hi Torsten,

We couldn’t recreate your issue. Here is a test Database with a new column named “open”, (it shares the same ConnectionString/password with our online test DB which you can easily find in the HowDoI sample)

and the following code works fine without issues:

SqlServerFeatureLayer coyoteSightingsLayer = new SqlServerFeatureLayer("Server=demodb.thinkgeo.com;Database=thinkgeo;User 
Id=ThinkGeoTest;Password=ThinkGeoTestPassword;", "frisco_coyote_sightings2", "id");
coyoteSightingsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

// Add the layer to the overlay we created earlier.
coyoteSightingsOverlay.Layers.Add("Coyote Sightings", coyoteSightingsLayer);

// Set a point style to zoom level 1 and then apply it to all zoom levels up to 20.
coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new 
PointStyle(PointSymbolType.Circle, 12, GeoBrushes.Black, new GeoPen(GeoColors.White, 1));
coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

// Set the map view current extent to a bounding box that shows just a few sightings.  
mapView.CurrentExtent = new RectangleShape(-10784283, 3918532, -10781699, 3916820);

// Refresh the map.
await mapView.RefreshAsync();

I’m on v13.2.0

Thanks,
Ben