ThinkGeo.com    |     Documentation    |     Premium Support

V12.1 - ExecuteQuery Issues

ThinkGeo Team,

I’ve run into two issues in V12.1 regarding ExecuteQuery. The exact same code runs under V10.6 without issue.

First, FeatureLayer.CanExecuteSqlQuery is always false for ShapeFileFeatureLayer. If an ExecuteQuery is attempted an Exception is encountered as shown below.

Second, FeatureLayer.ExecuteQuery when FeatureLayer is SqliteFeatureLayer returns an Exception for the following SqlStatement – Select * FROM [Transportation] as shown below.

However, the following ExecuteQuery for SqliteFeatureLayer returns the column schema as expected – Select * FROM [Transportation] Where 1=0.

I will send a DropBox link for the Transportation.sqlite FeatureLayer.

Both of these worked under V10.6.

Regards,
Dennis

Sql=Select * FROM [TransportationDup]
Source=ThinkGeo.Core
TargetSite=Void CheckFeatureSourceCanExecuteSqlQuery(Boolean)
StackTrace= at ThinkGeo.Core.ValidatorHelper.CheckFeatureSourceCanExecuteSqlQuery(Boolean canExecuteSqlQuery)
at ThinkGeo.Core.FeatureSource.ExecuteQuery(String sqlStatement)
at OriStarGeoCode.clsDbfFeatureSetItemsCollection.LoadDbfFeatureSetItem(String TheDatabase, String TheDatabaseTable, FeatureLayer& TheStreetsFeatures, Delegate TheProgressBar, Double TheRangeFactor) in C:\OriStarMappingIncThinkGeoUI-V12.1\OriStarGeoCode\clsDbfFeatureSet.cs:line 405
Message=Executing sql queries is not supported and the user should always check the CanExecuteSqlQueries to ensure the FeatureSource support it before calling.
System.InvalidOperationException: Executing sql queries is not supported and the user should always check the CanExecuteSqlQueries to ensure the FeatureSource support it before calling.
at ThinkGeo.Core.ValidatorHelper.CheckFeatureSourceCanExecuteSqlQuery(Boolean canExecuteSqlQuery)
at ThinkGeo.Core.FeatureSource.ExecuteQuery(String sqlStatement)
at OriStarGeoCode.clsDbfFeatureSetItemsCollection.LoadDbfFeatureSetItem(String TheDatabase, String TheDatabaseTable, FeatureLayer& TheStreetsFeatures, Delegate TheProgressBar, Double TheRangeFactor) in C:\OriStarMappingIncThinkGeoUI-V12.1\OriStarGeoCode\clsDbfFeatureSet.cs:line 405

TheDatabase=Transportation.sqlite, TheDatabaseTable=Transportation
Sql=Select * FROM [Transportation]
Source=System.Data.Common
TargetSite=Void set_Item(Int32, System.Object)
StackTrace= at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at ThinkGeo.Core.SqliteFeatureSource.ExecuteQueryCore(String sqlStatement)
at ThinkGeo.Core.FeatureSource.ExecuteQuery(String sqlStatement)
at OriStarGeoCode.clsDbfFeatureSetItemsCollection.LoadDbfFeatureSetItem(String TheDatabase, String TheDatabaseTable, FeatureLayer& TheStreetsFeatures, Delegate TheProgressBar, Double TheRangeFactor) in C:\OriStarMappingIncThinkGeoUI-V12.1\OriStarGeoCode\clsDbfFeatureSet.cs:line 405
Message=Unable to cast object of type ‘System.Byte[]’ to type ‘System.IConvertible’.Couldn’t store <System.Byte[]> in ColumnOrdinal Column. Expected type is Int32.
InnerException:
Source=System.Data.Common
TargetSite=Void Set(Int32, System.Object)
StackTrace= at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)
Message=Unable to cast object of type ‘System.Byte[]’ to type ‘System.IConvertible’.
System.ArgumentException: Unable to cast object of type ‘System.Byte[]’ to type ‘System.IConvertible’.Couldn’t store <System.Byte[]> in ColumnOrdinal Column. Expected type is Int32.
—> System.InvalidCastException: Unable to cast object of type ‘System.Byte[]’ to type ‘System.IConvertible’.
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)
— End of inner exception stack trace —
at System.Data.DataColumn.set_Item(Int32 record, Object value)
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at ThinkGeo.Core.SqliteFeatureSource.ExecuteQueryCore(String sqlStatement)
at ThinkGeo.Core.FeatureSource.ExecuteQuery(String sqlStatement)
at OriStarGeoCode.clsDbfFeatureSetItemsCollection.LoadDbfFeatureSetItem(String TheDatabase, String TheDatabaseTable, FeatureLayer& TheStreetsFeatures, Delegate TheProgressBar, Double TheRangeFactor) in C:\OriStarMappingIncThinkGeoUI-V12.1\OriStarGeoCode\clsDbfFeatureSet.cs:line 405

Thanks Dennis,
1. As talked with developer team. The V12 shapefeaturesource does not support the SqlQuery. Because in mapsuite 12 we support both .Net core and .Net Framework. But the .Net core won’t support the oledb(in V10 we use this one to query the dbf file). So we always return false for the ShapeFeatureSource.CanExecuteSqlQuery

  1. For SqliteFeatureLayer ExecuteQuery. We do have some issues for this one. We have fixed it. You could get the latest V12 nugget package and try again.

Thanks

Frank

hi Frank,

I upgraded to ThinkGeo.Core V13.0.0-beta160 which requires version 2.0.2 of the SQLitePCLRaw assemblies.

Would you please point me to the proper nugget for these?

I’ve located the assemblies.

Thanks,
Dennis

Frank,

I upgraded and now ExecuteQuery works on SqliteFeatureLayer.

Unfortunate about OleDb. I only need ExecuteQuery on ShapeFileFeatureLayer on a couple support applications so I will leave those as V10.6.

I had been using MS-Access for application configuration, but since it uses OleDb I had to upgrade to SQLExpress, which was a good thing. So I can understand you not supporting OleDb.

Thanks for your help.

Dennis

Thanks Dennis,
Thanks for understanding. Go ahead let us know if you have any more questions.

Thanks

Frank