ThinkGeo.com    |     Documentation    |     Premium Support

Exception with Where Clause and MsSql2008FeatureLayer

Hi Guys,


I tried the this where clause when adding a MsSql2008Feature layer to my map:


"WHERE CountyID=5 OR CountyID=6 OR CountyID=7"


When the map refreshes I get the following exception:



System.Data.SqlClient.SqlException was unhandled
  Class=16
  ErrorCode=-2146232060
  LineNumber=1
  Message=The query processor could not produce a query plan for a query with a spatial index hint.  Reason: Could not find required comparison predicate.  Try removing the index hints or removing SET FORCEPLAN.
  Number=8635
  Procedure=""
  Server=STEVEM6500\WOOFPUPPY
  Source=.Net SqlClient Data Provider
  State=10
  StackTrace:
       at ThinkGeo.MapSuite.Core.MsSql2008FeatureSource.Gj4=(RectangleShape Gz4=, Int32 HD4=, IEnumerable`1 HT4=)
       at ThinkGeo.MapSuite.Core.MsSql2008FeatureSource.GetFeaturesInsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable`1 returningColumnNames)
       at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawingCore(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable`1 returningColumnNames)
       at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable`1 returningColumnNames)
       at ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
       at SerializeWMSLayer.CustomSqlLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers) in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SQLServerLayer\CustomSqlLayer.vb:line 9
       at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
       at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)
       at ThinkGeo.MapSuite.DesktopEdition.Overlay.rRM=(GeoCanvas rhM=)
       at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.1BU=(IEnumerable`1 1RU=)
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.0hU=(RectangleShape 0xU=)
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.IRY=()
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.HRY=(Int32 HhY=)
       at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh()
       at SerializeWMSLayer.Form1.LoadSQLSpatialLayer2() in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SQLServerLayer\Form1.vb:line 89
       at SerializeWMSLayer.Form1.btnLoad_Click(Object sender, EventArgs e) in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SQLServerLayer\Form1.vb:line 99
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at SerializeWMSLayer.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 


If I change the where clause to the following adding parentheses) it works fine:


"WHERE (CountyID=5 OR CountyID=6 OR CountyID=7)"


Thanks,


Steve


 



Hi Steven, 
  
 Please get the latest version 6.0.341.0 or 6.0.0.341 and have a try, it shoudl work without the parentheses now. 
  
 Regards, 
 Edgar

Hi Edgar, 
  
 It’s working now, thanks! 
  
 Steve

You’re welcome Steve, if you have any questions please let us know. 
  
 Regards, 
 Edgar