Select to view content in your preferred language

How to delete feature dataset and feature class SDE  ?

5619
4
02-25-2014 04:57 AM
TaiBui
by
Frequent Contributor
Hi everyone,

Are there anyone know the statements/methods to delete a SDE feature dataset and a SDE feature class from SDE database ? (using C# or VB)

Thank you very much.

Tai
0 Kudos
4 Replies
NeilClemmons
Honored Contributor
Use IDataset.Delete.  I would imagine you can't delete feature datasets unless they are empty though.
0 Kudos
TaiBui
by
Frequent Contributor
Use IDataset.Delete.  I would imagine you can't delete feature datasets unless they are empty though.


Thanks Neil,

I got the error: Layer in use SDE when trying to delete.

Please see my code:

                        IDataset pdataset;
                        pdataset = (ESRI.ArcGIS.Geodatabase.IDataset)featureClass;

                        if (pdataset.CanDelete() && pdataset != null)
                            pdataset.Delete();            // Throw exception


Do you know how to fix this ?

Thanks and regards,

Tai
0 Kudos
NeilClemmons
Honored Contributor
Where is the feature class in use?  If it's in your map document then you probably need to disconnect the layer from its data source (IDataLayer2.Disconnect) and delete it from the map.
0 Kudos
RobertBorchert
Honored Contributor
Compress your database, you should unregister as versioned those what you wish to delete.  compress it again.

shut down all programs accessing the SDE, compress it and try it again.  if that does not work go into SQL Server Configuration Manager and restart the service.  That will issue a kill command to anything connected.



Where is the feature class in use?  If it's in your map document then you probably need to disconnect the layer from its data source (IDataLayer2.Disconnect) and delete it from the map.
0 Kudos