Select to view content in your preferred language

How to catch the Field name and syntax mismatch error.

632
2
08-27-2010 11:55 PM
papegowda
Emerging Contributor
Hi all,

I am using ArcGIS explorer 1200 SDK, and I am trying to build a small tool to select feature attributes using query string.

I am selecting the Features in a feature layer using the following syntax. And its working fine

Dim FL As FeatureLayer
FL = ESRI.ArcGISExplorer.Application.Application.SelectedItems(0)

Dim row As RowCollection
Row = FL.Table.Search(New Filter("STATUS = 1"))

If I use the field name as STATUS1 (the ???STATUS1??? field does not exist in the selected feature layer) then it is not showing any error. Only thing it is not selected any rows.

I wanted to catch this type of error. Can you please help me on this?

Or any other alternate method where I can catch this type of errors.

Regards,
Pape Gowda
0 Kudos
2 Replies
ShellyGill2
Regular Contributor
Hi,

Search will return an empty collection if the search fails for any reason, so there is no exception thrown that you can catch here.

If you find an empty collection being returned, and you suspect a field name error, you can check the Columns of the FeatureLayers Table, maybe try the ColumnCollection.FindColumn method to see if the column exists (-1 will be returned if the column name doesnt exist.

There's no expression validator built in to the API I'm afraid, so that would be trickier to write. If there's still no records returned, it might either be a valid result (there's nothing matching that expression) or the expression might be incorrect - you can test the expression using the Query button in the app to see if that's the case.
0 Kudos
papegowda
Emerging Contributor
Thanks sgill,

first i have used this method to verify the query, and it is difficult to verify the field names if query contains multiple field names.

since it will not catch any syntax and field name errors, i have decided to convert the feature table to data table and it worked well for me. only constant my code runs slow while converting feature table to data table.


Regards,
Pape gowda.
0 Kudos