HI, My objective is to export a featureclass to sde.
My code is as follows:
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("SERVER", "3019-h2-xyz");
propertySet.SetProperty("INSTANCE", "SDE:SQLSERVER:TEMP-INS-COM");
propertySet.SetProperty("DATABASE", "foo");
propertySet.SetProperty("AUTHENTICATION_MODE", "OSA");
propertySet.SetProperty("VERSION", "dbo.DEFAULT");
IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();
IFeatureWorkspace pArcSDEFeatureWorksapce = workspaceFactory.Open(propertySet, 0) as IFeatureWorspace
IWorkspace2 pWS2 = pArcSDEFeatureWorksapce as IWorkspace2;
if (pWS2.get_NameExists(esriDatasetType.esriDTTable, intersect_featurename))
{
IDataset pExistingDataset = pArcSDEFeatureWorksapce.OpenTable(intersect_featurename) as IDataset;
if (pExistingDataset.CanDelete())
{
pExistingDataset.Delete();
}
}
Geoprocessor pGp = new Geoprocessor();
DisplayMessage("Exporting to SDE....");
TableToGeodatabase pTableToGeodatabase = new TableToGeodatabase();
pTableToGeodatabase.Input_Table = intersectOutputFeatureClass.AliasName;
pTableToGeodatabase.Output_Geodatabase = pArcSDEFeatureWorksapce;
pGp.Execute(pTableToGeodatabase, null);
The pArcSDEFeatureWorksapce allows me to retrieve and delete any feautureclasses. Also if I connect to this database connection in arccatalog and then run this code it exports a featureclass to sde. But if the connection in arc-catalog is disconnected the execution fails. If I am connecting to an arcsde workspace programmatically then why do I have to connect to an existing connection and then execute the tool?
Also this connection works fine in model builder without having me connect a connection in catalog.
Regards,
Nigel.