[gdal-dev] Ogr: ExecuteSQL with MSSQL and geometry column

Benjamin benjamin.lux at maxsea.fr
Tue Jul 17 07:37:08 PDT 2012


Hi,

I code an application with a warper C# of Ogr.
I have a MSSQL data base which work fine with Ogr (except this issue).
I have a table dbo.MY_TABLE with 3 fields (D, CHART_ID, WKB_GEOMETRY).

To minimise my acces to SQL Serveur (Driver MSSQLSpatial) I want to copy a
request SQL into a Spatial Layer (with a geometry column) based on a Memory
Driver.
To obtain my layer I call ExecuteSQL().

[code]
string options =  "Tables=dbo.MY_TABLE(WKB_GEOMETRY);GeometryFormat=wkb;"
serverDataSource = Ogr.Open("MSSQL:" + connectionString + options), 0);

string request = "SELECT * FROM MY_TABLE WHERE CHART_ID = 'ID'"
Layer serverLayer = serverDataSource.ExecuteSQL(request, null, "");
[/code]

I see that my layer name is "SELECT", it have 39 features but my result
doesn't contain geometry column !
Why ?
serverLayer.GetGeometryColumn() returns "" and serverLayer.GetGeomType()
returns "wkbUnknown".

And the layer serverLayer ( or a layer provide by a Memory Driver) have any
method "ChoseGeometryField" or "SetGeometryColumn" (or I have missed it).


If I call serverDataSource.GetLayerByName("MY_TABLE").GetGeometryColumn() it
work fine and result "WKB_GEOMETRY".

Any suggests ?

Regards,
Benjamin.



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/gdal-dev-Ogr-ExecuteSQL-with-MSSQL-and-geometry-column-tp4988831.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list