1

I'm trying to join a single column from one feature class to another inside a File GDB using C# and the ESRI.ArcGIS.DataManagementTools.JoinField class. I've gotten several other geoprocessing functions to work, but for this one I don't think I have the correct input to the 'fields' property to specify the column to be joined and the gp.Execute() throws a COM exception. I've tried an IFields object (in the code below), I've tried a simple text string with the name of the field. They both throw a COM exception with no useful information.

    IFeatureClass parcelsExportFC = exportFws.OpenFeatureClass(parcelsExportFClassName);
    IFeatureClass parcelsZoneJoin = exportFws.OpenFeatureClass(String.Format("{0}_ZONEJOIN", parcelsExportFClassName));
    Int32 parcelsExportOIDFieldIdx = parcelsExportFC.Fields.FindField("OBJECTID");
    Int32 parcelsZoneJoinOrig_OIDFieldIdx = parcelsZoneJoin.Fields.FindField("ORIG_OID");
    IField parcelsExportOIDField = parcelsExportFC.Fields.get_Field(parcelsExportOIDFieldIdx);
    IField parcelsZoneJoinOrig_OIDField = parcelsZoneJoin.Fields.get_Field(parcelsZoneJoinOrig_OIDFieldIdx);
    JoinField jf = new JoinField(parcelsExportFC, parcelsExportOIDField, parcelsZoneJoin, parcelsZoneJoinOrig_OIDField);
    //this is the field I want to join
    IField zoneCodeField = parcelsZoneJoin.Fields.get_Field(parcelsZoneJoin.FindField("ZONE"));
    IFieldsEdit fields = new FieldsClass();
    fields.FieldCount_2 = 1;
    fields.set_Field(0, zoneCodeField);
    jf.fields = (IFields)fields;
    Geoprocessor gp = new Geoprocessor();
    gp.Execute(jf, null);

Any ideas?

1 Answer 1

0

So I had some JoinField parameters ordered wrong, and it works if you specify a text field like so:

    jf.fields = "AvistaCode";

Not sure how you would specify multiple fields though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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