jtkknelson

Append_management Tool FieldMapping Problem C#

Discussion created by jtkknelson on Mar 21, 2012
Latest reply on May 19, 2018 by Grieck
I have two File GeoDatabases with the identical structures and I am trying to get the Append_management tool to populate the fields when using the ???No_Test??? parameter. It works when I use the ???Test??? parameter. The ???No_Test??? parameter adds the features but none of the attributes. So am thinking that I need to map the fields. How do you map the matching fields for input into the Append_management tool?


//strings ->  input, output (complete path to the geodatabase featureclass in different geodatabase)
//The featureclass have identical structures
                           
IGeoProcessor gp = new GeoProcessor();
IVariantArray parameters = new VarArrayClass();
IFeatureClass iFC;
IFeatureWorkspace iFWS;
FeatureClassUtils iFCU = new FeatureClassUtils();

iFWS = (IFeatureWorkspace)iFCU.FileGdbWorkspaceFromPath(txtGeodatabase.Text);
iFC = iFWS.OpenFeatureClass(chkFeatureclasses.Items[i].ToString());


//From ESRi SAMPLE
IGPUtilities gputilities = new GPUtilitiesClass();
IGPFieldMapping fieldmapping = new GPFieldMappingClass();
IDETable outTableA = (IDETable) gputilities.MakeDataElement(input,null,null);
IDETable inputTableA = (IDETable)gputilities.MakeDataElement(output, null, null);
IArray inputtables = new ArrayClass();
inputtables.Add(outTableA);
//inputtables.Add(inputTableA);
fieldmapping.Initialize(inputtables, null);
//End Sample Code

                                                
parameters.Add(iFC);
parameters.Add(output);
parameters.Add("NO_TEST");
//parameters.Add("TEST"); //worked populates values
parameters.Add(fieldmapping); // also tried parameters.Add("fieldmapping")
//parameters.Add(""); appends feature but doesn't populate fields (All fields have same structure)
parameters.Add("");
gp.Execute("Append_management", parameters, null);
parameters.RemoveAll();

Outcomes