I am not using arcmap but I am creating a arcgis desktop console app. I am pulling an external SQL table in as a querylayer. This table has lat & long so I created an eventlayer (or IXYEventSource xyEventSource). Now I want to export it to SDE as a featureclass but now I am stuck which route to take. Eventually, I want to put this exe in windows scheduler. Any ideas on how to export to SDE? Thanks,



An IXYEventSource is a FeatureClass, so you can treat it (i.e copy it) like any other FeatureClass.

There are so many ways of doing this, but one of the easier ones it to use the IFeatureDataConverter::ConvertFeatureClass method. The description is confusing (some people interpret it that it only works on Personal GDBs - but it works for Enterprise GDBs, too).

Update: Another option is the SimpleDataConverter here is an slightly modified extract from some other code I wrote awhile back.

  IFeatureClass m_pSourceDataset = myXYEventFC as IFeatureClass

  IFeatureClass pSourceFeatureClass = m_pSourceDataset as IFeatureClass;

  ISimpleDataConverter2 pDataConverter = new SimpleDataConverterClass();
  pDataConverter.InputDatasetName = m_pSourceDataset.FullName as IDatasetName;
  pDataConverter.InputQueryFilter = pInputQF;
  pDataConverter.OutputFeatureDatasetName = pOutputFD.FullName as IFeatureDatasetName;
  pDataConverter.OutputGeometryDef = pSourceFeatureClass.Fields.get_Field(pSourceFeatureClass.FindField(pSourceFeatureClass.ShapeFieldName)).GeometryDef;
  pDataConverter.OutputFields = pSourceFeatureClass.Fields;

  IEnumInvalidObject ipEnumInvalidObject = pDataConverter.Convert();

  // Get the unqualified name of input FC and use it to open output fc
  ISQLSyntax pSQLSyntax = pFWS as ISQLSyntax;
  String strOwnerName, strTableName, strDBName;
  pSQLSyntax.ParseTableName(m_pSourceDataset.Name, out strDBName, out strOwnerName, out strTableName);

  IFeatureClass pOutputFC = pFWS.OpenFeatureClass(strTableName) as IFeatureClass;
| improve this answer | |
  • Thanks, I actually started looking at a different approach, the geoprocessor [help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/…. And use the copy tool. does anyone know how to make this work? How do you set geoprocessor.SetEnvironmentValue() equal an IXYEventSource or IFeatureclass which came from a querylayer? Also, I would like to know performance difference between IFeatureDataConverter, geoprocessor and others. – saim Apr 26 '11 at 18:12
  • As far as the speed difference goes, you only pay a few seconds and the beginning and the end to initialize and finalize the GP system. Otherwise, the internal implementation uses ArcObjects, so it will be the same :) – Ragi Yaser Burhum Apr 27 '11 at 1:58
  • Thanks Ragi, I tried using IFeatureDataConverter. Once I figured out all the IFeatureDataConverter.ConvertFeatureClass parameters, the whole thing bombed on IEnumInvalidObject enumErrors = fctofc.ConvertFeatureClass(sourceFeatureClassName, queryFilter, null, targetFeatureClassName, geometryDef, targetFeatureClassFields, "", 1000, 0); Error: Attempted to read or write protected memory? Not sure what caused it so I switched to ISimpleDataConverter. – saim Apr 27 '11 at 14:31
  • and that worked fine, right? – Ragi Yaser Burhum Apr 27 '11 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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