I want to make use of geoprocessing via .NET ArcObjects, in this case of the "Erase" tool. This is easy once dealing with a local gdb file what I did for feasibility study. The issue occurs when I want to work on feature classes of MS SQL ArcSDE database. Normally, all operations are done on a IWorkSpace that is created and opened. Here, this page http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Working_with_ArcSDE_data/0001000001zs000000/ states that I can either use so called .sde file or property set. So I tried to use the PropertySet I created for the IWorkspace before, but it did not work - it expects IVariantArray. In the aforementioned website, iVariantArray is used to launch a tool that creates the .sde file. There is no description on the order of parameters passed, I can only guess what means what.

Obviously I understand, that I need to pass also the three parameters for Erase tool: in_features,out_feature_class and erase_features. Can someone please explain to me how can I do that?

Am I doing something wrong? I can't understand why is the creation of .sde file described in the topic concerning geoprocessing, while it's clearly missing the description of a second way to connect via property set.


1 Answer 1


You need to create the SDE connection file in order to reference it when calling your 'erase' geoprocessing tool. For example, if you wanted to pass a SDE feature class to a geoprocessing tool, the path will something along the lines of

<some location>\mySDEConnectionFile.sde\myFeatureClass

But in order to create this SDE connection file (.SDE) you need to use the geoprocessing tool mentioned in the link you provided. This will be the tricky part as there are a lot of parameters to pass in order to create it. But just follow the code example. Here is the link to the page describing the order of parameters passed to the tool:


Once you have your SDE connection file created, you can pass it as a parameter to your erase geoprocessing tool, you'll do something like this (sorry it's in VB)

Dim gp As IGeoprocessor = New Geoprocessor
Dim var As IVariantArray = New VarArray()
With var
    .Add(<input features>)
    .Add(<erase features>)
End With
gp.Execute("EraseTool", var, nothing)

Something similar to that anyway. Do you have a link to the erase tool you're trying to run? I can't find a reference to it.

  • You don't have to use SDE connection files with ArcObjects: help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/…
    – blah238
    Jun 10, 2014 at 13:57
  • Here it is help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… The point is, I would like to connect without using SDE connection file, just by passing the path to DB and credentials. I can't find a way to do this.
    – Konrad
    Jun 10, 2014 at 14:01
  • In that case this post might help you: gis.stackexchange.com/questions/35667/…
    – pvdev
    Jun 10, 2014 at 14:18
  • I tried this too, in fact this is the way I tried to approach this issue from the start. The problem is Erase tool has no in_workspace parameter exposed, hence I can't pass my workspace object.
    – Konrad
    Jun 10, 2014 at 14:37
  • There's a small chance you might already have a connection file to your SDE database in ArcCatalog appdata directory which you could reference: C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog
    – pvdev
    Jun 10, 2014 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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