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.

I need to query two feature class at the same time using IQueryFIlter.

For eg -

FeatureClass -- A has field OBJECTID

FeatureClass -- B has field OBJECTID

what i am tring to do is --

IQueryFilter iqf = new QueryFilter();
iqf .setWhereClause(B+".OBJECTID = "+A+".OBJECTID");
IFeatureCursor resultCursor = B.search(iqf, false);  

Is this possible , if yes what is the correct methord because currently i am facing error--

"Too few parameters. Expected 1"

Might its not taking A.OBJECTID properly ////

share|improve this question
1  
Did you read about joining tables in the online docs? –  Kirk Kuykendall Jul 3 '13 at 13:05
1  
IQueryFilter isn't really designed to join tables. For that you should be using a IQuerDef. resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/… –  travis Jul 3 '13 at 19:22
add comment

1 Answer

up vote 2 down vote accepted

It is difficult to do anything but the simplest queries in ArcObjects. Here is a method to create an in memory join between 2 tables.

public static ITable Join(string relationshipName, ITable tableA, ITable tableB, string tableAJoinField, string tableBJoinField, IQueryFilter queryF, string targetFields, esriJoinType joinType, esriRelCardinality cardinality)
        {
            IMemoryRelationshipClassFactory mrcFactory = new MemoryRelationshipClassFactoryClass();
            IRelationshipClass relationship = mrcFactory.Open(
                relationshipName,
                (IObjectClass)tableA, tableAJoinField,
                (IObjectClass)tableB, tableBJoinField,
                "forward", "backward",
                cardinality);

            // Open the RelQueryTable
            IRelQueryTableFactory rqtFactory = new RelQueryTableFactoryClass();

            bool joinForward = true;
            bool doNotPushJoinToDb = true;
            bool openAsLeftOuterJoin = (joinType == esriJoinType.esriLeftOuterJoin);

            IRelQueryTable relQueryTable = rqtFactory.Open(relationship, joinForward, queryF, null, targetFields, doNotPushJoinToDb, openAsLeftOuterJoin);
            ITable joinTable = relQueryTable as ITable;

            return joinTable;
        }
share|improve this answer
    
Thanks it helped a lot .Just waiting for some more suggetions , if not will mark yours as answer.//// –  NewBee Jul 3 '13 at 13:18
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.