ThinkGeo.com    |     Blog    |     Wiki    |     Support

QueryTools.ExecuteQuery() Exception Handling

Is there a way to handle exceptions for QueryTools.ExecuteQuery. I have a SQL statement that is having errors which I know I can fix but I would like my program to handle an exception when the function fails. When I run the below code the query fails and crashes the program because of column values which change without warning and I would like to have it handled instead of crashing/breaking.

FileGeoDatabaseFeatureLayer Layer = Overlay.Layers[0] as FileGeoDatabaseFeatureLayer;
Layer.Open();
try
{
SearchResults = Layer.QueryTools.ExecuteQuery(sbSQL.ToString());
}
catch
{
// failed search
}
Layer.Close();

Hi Chad5,

The ExecuteQuery call other dll by reflection function, so the try catch won’t works, please try AppDomain.UnhandledException and see whether it works for your scenario.

Regards,

Ethan