Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Thanks,

// 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;
share|improve this question
add comment

1 Answer

I would first check to see if your where clause is valid and it does return data. Another suggestion would be to use the IFeatureLayerDefinition to setup a QueryDef since you are only using a single table - An example here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.