SqlServer Spatial : Can't use SqlDataReader on Geometry
|Reported by:||bscott||Owned by:||danstoica|
SqlDataReader throw an exception if there is a geometry column in the SQL statement. Exception : RDBMS(ODBC): Geometry conversion error. Explanation: When the SqlServer Spatial provider get geometries from SqlServer it expect to have wkb Geometry. FeatureReader concatenate the "STAsBinary()" function to the geometry column name before sending the query to SqlServer but SqlDataReader does not do that.
My suggestion would be to remove the STAsBinary function from the FeatureReader and handle the convertion directly in the geom_convertFromSqlServer_S (Geom.c) function. I don't know exactly how to do that, maybe there is an internal SqlServer API that can does that for us?
In the mean while i think it would be better if the provider returns null Geometry if it can't convert it. Actually it throws an exception and the SqlDataReader become useless as soon as the table has a geometry column.