ThinkGeo.com    |     Documentation    |     Premium Support

ExecuteScalar issue

 


Hi,


I have a Shapefile layer that I want to query a value from.



Dim



 CntyLayer As New ShapeFileFeatureLayer(MAPLayersPath + "\" + COUNTYBORDER_LayerFile)


Thanks , Madduri



 


CntyLayer.Open()


Dim layerName = System.IO.Path.GetFileNameWithoutExtension(COUNTYBORDER_LayerFile)Dim CntyName = CntyLayer.QueryTools.ExecuteScalar("SELECT " & CountyName & " FROM " & layerName & " WHERE " & CountyCode & "=" & RoadwayCounty)


CntyLayer.Close()

I keep getting the following error:


The Microsoft Jet database engine could not find the object 'County_Boundary'.  Make sure the object exists and that you spell its name and the path name correctly.


The sql query evaluates to:



"SELECT CNTY_NAME FROM County_Boundary WHERE CNTY_CODE=1"



I have checked that the dbf file and shp files exist in the path. Also the layer appears correctly on the map. What am I doing wrong here?




Madduri, 
  
 Thanks for your post and question! 
  
 We tried the code with a different data, and it works fine. So I doubt the data you are using is the reason for this problem, could you send me your data for this? 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale 


Hi,


Attached zip file contians the data.


Thanks for your help.


-Madduri



1136-County_Boundary.zip (91.6 KB)

 


Madduri,
 
You missed the .shx file :). Could you upload the corresponding .shx file?
 
Thanks.
 
Yale

Madduri, 
  
 We found that root reason for this problem, the length of the file name should be less than 8 characters. It seems that OLEDB does not support it. 
  
 You can rename it to Boundary.shp or something. 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale 


Thank you. Really appreciate you looking into this.


I have implemented a workaround for this issue. I was able to use the find features containing method to get the value I need. It worked out in the current situation, but I will check file name length if I have to query for a value in the future.


Regards


madduri



Madduri, 
  
 Thanks for letting us know your status! 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale