Select to view content in your preferred language

Append command fails to copy attributes Why (C#)?

1014
0
03-23-2012 01:15 PM
JohnNelson3
Occasional Contributor
When I make a duplicate copy of an ArcMap 10 file geodatabase and try to append a featureclass, the "NO_TEST" option only copies the features without the attributes. The "TEST" option copies both - WHY??? Do I have something wrong in the code below? I found this code on the web and modified it to go from geodatabase to geodatabase. My original code had the same results.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.DataManagementTools;
using ESRI.ArcGIS.DataSourcesGDB;

namespace Bug
{
    public class Bug : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        public Bug()
        {
        }

        protected override void OnClick()
        {
            //
            //  TODO: Sample code showing how to access button host
            //
            ArcMap.Application.CurrentTool = null;
            try
            {
                ESRI.ArcGIS.Geodatabase.IWorkspace pWorkspace;
                ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFactory;
                ESRI.ArcGIS.Geodatabase.IFeatureWorkspace SdeFeatureWorkspace;

                pWorkspaceFactory = new FileGDBWorkspaceFactory();
                pWorkspace = pWorkspaceFactory.OpenFromFile(@"R:\loc\GIS\PROJECTS\cultural\Development\CulturalTemp_1.gdb", 0);
                SdeFeatureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)pWorkspace;

                IFeatureClass featureClass = SdeFeatureWorkspace.OpenFeatureClass("FeatArt_point");


                Geoprocessor gp = new Geoprocessor();
                gp.SetEnvironmentValue("workspace", @"R:\loc\GIS\PROJECTS\cultural\Temporary Database\CulturalTemp.gdb");

                ESRI.ArcGIS.DataManagementTools.Append append = new ESRI.ArcGIS.DataManagementTools.Append();
                append.inputs = featureClass;
                append.target = @"R:\loc\GIS\PROJECTS\cultural\Temporary Database\CulturalTemp.gdb\FeatArt_point";
                append.schema_type = "NO_TEST";
                gp.Execute(append, null);
            }
            catch
            {
               
            }

        }


        protected override void OnUpdate()
        {
            Enabled = ArcMap.Application != null;
        }
    }

}
0 Kudos
0 Replies