Benjamin,<br><br>The name 'SELECT' is intentional. We can't set it to the table's name. The select command could be a complex one involving multiple tables.<br><br>The result layer has the native OGR format. The geometry is separate from the attributes/fields. So, there will be no geometry column in it. You can access the geometry like with any other ogr feature.<br>
<br>For a table, the geometry type is determined by reading the dbo.geometry_columns table. For the result layer there is no easy way to do it and is set to wkbUnknown. In any case, you should be able to use those geometry objects like any other.<br>
<br><br><div class="gmail_quote">On Tue, Jul 17, 2012 at 8:07 PM, Benjamin <span dir="ltr"><<a href="mailto:benjamin.lux@maxsea.fr" target="_blank">benjamin.lux@maxsea.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I code an application with a warper C# of Ogr.<br>
I have a MSSQL data base which work fine with Ogr (except this issue).<br>
I have a table dbo.MY_TABLE with 3 fields (D, CHART_ID, WKB_GEOMETRY).<br>
<br>
To minimise my acces to SQL Serveur (Driver MSSQLSpatial) I want to copy a<br>
request SQL into a Spatial Layer (with a geometry column) based on a Memory<br>
Driver.<br>
To obtain my layer I call ExecuteSQL().<br>
<br>
[code]<br>
string options =  "Tables=dbo.MY_TABLE(WKB_GEOMETRY);GeometryFormat=wkb;"<br>
serverDataSource = Ogr.Open("MSSQL:" + connectionString + options), 0);<br>
<br>
string request = "SELECT * FROM MY_TABLE WHERE CHART_ID = 'ID'"<br>
Layer serverLayer = serverDataSource.ExecuteSQL(request, null, "");<br>
[/code]<br>
<br>
I see that my layer name is "SELECT", it have 39 features but my result<br>
doesn't contain geometry column !<br>
Why ?<br>
serverLayer.GetGeometryColumn() returns "" and serverLayer.GetGeomType()<br>
returns "wkbUnknown".<br>
<br>
And the layer serverLayer ( or a layer provide by a Memory Driver) have any<br>
method "ChoseGeometryField" or "SetGeometryColumn" (or I have missed it).<br>
<br>
<br>
If I call serverDataSource.GetLayerByName("MY_TABLE").GetGeometryColumn() it<br>
work fine and result "WKB_GEOMETRY".<br>
<br>
Any suggests ?<br>
<br>
Regards,<br>
Benjamin.<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/gdal-dev-Ogr-ExecuteSQL-with-MSSQL-and-geometry-column-tp4988831.html" target="_blank">http://osgeo-org.1560.n6.nabble.com/gdal-dev-Ogr-ExecuteSQL-with-MSSQL-and-geometry-column-tp4988831.html</a><br>

Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E<br>