SpatiaLite Query string

Jun 18, 2012 at 1:13 PM

When I run SpatiaLite Query within "SpatialiteHelper.cs" the SQL Query string like this works OK:
select * from my_table

But the SQL Query string bellow is not working:
select name, description from my_table

Here bellow arrises a problem:

        public IFeatureSet ReadFeatureSet(string connString, string sqlQuery)       


//Find the geometry type and geometry column           

GeometryColumnInfo geomInfo = FindGeometryColumnInfo(connString, sqlQuery);            return ReadFeatureSet(connString, geomInfo, sqlQuery);       


Can someone please help me.
Regards, Vojko

Jun 18, 2012 at 7:10 PM

Which version of SpatiaLite did you create the database with?

If it was higher than 2.3, then the coord_dimension field is no longer an integer value (2-4) but instead one of 'XY', 'XYZ', 'XYM' or 'XYZM'.
These values can't be converted to an integer value, that is why the function fails.

Hth FObermaier

Jun 18, 2012 at 8:54 PM

My version of SpatiaLite is 2.3, but why "select * from mytable" works OK and "select name, desc from mytable" fails?

"Name" and "desc" are both string values! 

With Spatialite-gui v1.2 works both select statement OK.


Jun 19, 2012 at 5:51 AM
Edited Jun 19, 2012 at 5:53 AM

I think 'desc' is a sqlite keyword  (used in the order by clause) that you cannot use in a query unless you double quote it. (

Therefore you should query

SELECT name, "desc" from mytable;

or rename that column.

Jun 19, 2012 at 7:43 AM

Thanks to follow me the case is that both columns from SQL query are string and I put there "desc" for example.

The SQL query running within "SpatialiteHelper.cs":
select name_one, name_two from my_table
fails when call for
  public IFeatureSet ReadFeatureSet(string connString, string sqlQuery)     


Jun 19, 2012 at 9:08 AM

Does your query contain a geometry that is registered in the geometry_columns table?

If not, you won't get a GeometryColumnInfo object (FindGeometryColumnInfo) and the ReadFeatureSet function will fail.

Hth FObermaier

Jun 19, 2012 at 10:25 AM

thanks for answer now works OK