I'm trying to validate the results of a ISQLQueryDialog2, but can't find any out of the box solutions. This particular dialog has a built in validate button, but I would like to programmatically validate the SQL string against the feature class in question.

I've found ISQLCheck3, but the documentation for this is slim, as it's reserved for internal use only.

Is there a way to validate a SQL where clause?

EDIT: I've created a try/catch statement to attempt to use a QueryFilter, however this seems kind of hacky.

IQueryFilter qFilter = new QueryFilter();
qFilter.WhereClause = qDialog.SQLQuery; //result of ISQLQueryDialog2
try {
} catch (Exception ex) {
    MessageBox.Show("Houston, we have a problem");
  • If it ain't broke, no need to fix it... crash and burn works! This would be kind of 'hacky' if the execution of the dud SQL statement carried on for minutes before throwing the exception, but it should be thrown by the fc (IFeatureClass?) almost instantly. Though as you say ISQLCheck3 myCheck = (ISQLCheck3) new SQLCheck(); then myCheck.ValidateQueryFilter((fc as IDataset).Workspace,fc,qFilter,BoolValid); should do something. Yet another potentially helpful under-documented interface. – Michael Stimson Mar 27 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.