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 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,

saim

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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;
share|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
    
yes it did. Thanks! –  saim May 9 '11 at 2:40
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.