Jamari_L_Powers

Arc Objects - Evaluate entire query from string variable

Discussion created by Jamari_L_Powers on May 1, 2014
I have been working with ArcObjects using IQueryDef to create queries. Using IQueryDef incroporates the use of 'Subfields', 'Tables' and a 'WhereClause' to create the query definition. This works pretty well. However, I want to be able to work with arc objects and spatial data that runs a query without having to break it into Subfields, Tables, and a WhereClause.

I have a form that allows a user to enter in an entire query ( in the form SELECT * FROM myTable WHere ID = 7). I am able to grab this 'string' and store it in a variable. I want to be able to evaulate this string variable (or query) in arc objects. I had envisioned something along the lines of


ICursor _cursor = null;

string  _query = "SELECT * FROM myTable WHERE Id = 7";
IQueryDef _pdq = _pfeatureWorkspace.CreateQueryDef();
_cursor = _pdq.Evaluate(_query);



However, I;ve tried some variations of this and it is not successful. I get an error along the lines of "No overload for method".

I've been looking into using SQLCommand to capture the entire qurey as a single string and place it in a variable. More testing is needed there.

Any information on this topic would be greatly appreciated. Thanks in advance.

Outcomes