This is some code that I am using to try to get a working IFeatureLayer from a subset of data from a database table. The fourth line containing "fcWkspc.OpenFeatureQuery" throws and error complaining about an "The operation was attempted on an empty geometry.".
Should also mention that this code was lifted directly from ESRI documentation example code at the following link:
http://resources.esri.com/help/9.3/arcgisdesktop/arcobjects/esrigeodatabase/IQueryDef_Example.htm
Can anyone tell me what I might be doing wrong?
// m_wkSpace2 is of type IWorkspace2
IFeatureWorkspace fcWkspc = (IFeatureWorkspace)m_wkSpace2;
IQueryDef qDef = fcWkspc.CreateQueryDef();
Def.Tables = "dbo.TABLE_NAME";
qDef.WhereClause = "Name1 = '" + var1 + "' AND Name2 = '" + var2 + "'";
IFeatureDataset featureDataset = fcWkspc.OpenFeatureQuery("MyJoin", qDef);
IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset;
IFeatureClass featureClass = featureClassContainer.get_ClassByName("MyJoin");
IFeatureLayer layerForMap = (IFeatureLayer)featureClass;