I want to transfer all contents of a table from file geodatabase (*.gdb) to a table in ArcSde. In fact the data is meant to be replaced, so I need also to clear the table in ArcSde. Both tables have same structure. The target table is used in a map service.

I started with ConvertFeatureClass and the effects were pretty good - it was working, but each time it was creating a new table. Every try to append the data to already existing table ended with errors. Here's my code - http://pastebin.com/RWhMTe4p

Since this was not doing what I wanted, I tried something different. This time, I used IGeoDBDataTransfer interface. My efforts ended up with an error being thrown on the final Transfer method. That's my code - http://pastebin.com/MG3KUHdS The COMException is: "Error -2147216061: Exception from HRESULT: 0x80041543

Can someone please explain how to do this task?

  • I'm not personally that familiar with ArcObjects, but I know just using the standard geoprocessing tools in ArcGIS Desktop, a number of tools that modify the target data (rather than making new output copy) don't work at all or don't work as expected if running them against feature classes that are a data source for a currently running ArcGIS Server service. Depending on the service, various locks may be being placed on the data. I'd try stopping the map service, see if that fixes errors, to at least isolate problem. Good luck, hope it helps.
    – John
    Jun 23, 2014 at 16:32
  • Is your feature class versioned?
    – Conor
    Jun 23, 2014 at 17:12
  • No, it is not versioned.
    – Konrad
    Jun 23, 2014 at 22:10

1 Answer 1


As John has stated you probably have a lock on your database from the map service. If your feature class is not versioned and the features you are working with are not complex (i.e. they do not participate in a relationship class or a topology), you can do the following safely without interrupting your ArcSDE users:

  1. Use ISchemaLock to get an exclusive lock on the feature class.

    IMPORTANT: If you get a schema lock on a feature class it will put a lock on the entire feature dataset! So you may want to move all of this data into its own feature dataset if possible.

  2. Use ITableWrite2.Truncate to clear all of the data out of your table.

  3. Set IFeatureClassLoad.LoadOnlyMode to "True" on your SDE feature class. This will improve performance.

  4. Use a combination of search and insert cursors to loop over every row in your .gdb and insert into your ArcSDE feature class. Note that you don't necessarily have to use the FeatureBuffer/GeometryList in the example.

  5. Explicitly release your cursors using the normal System.Runtime.InteropServices.Marshal.ReleaseComObject(featCursor); method, then set IfeatureClassLoad.LoadOnlyMode to "False".

  6. Release your lock.

  • Just for a small check, I stopped the map service and just to be sure, I restarted MS SQL database service. It did not help, I'll try to use the functions you mentioned, maybe they will help.
    – Konrad
    Jun 23, 2014 at 22:12
  • In the Using load-only mode to insert rows section on the link in #4 you will find examples of implementing LoadOnlyMode & ISchemaLock. Good luck.
    – Conor
    Jun 23, 2014 at 22:25

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.