How to delete feature dataset and feature class SDE  ?

5227
4
02-25-2014 04:57 AM
TaiBui
by
Occasional Contributor II
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
Regular Contributor III
Use IDataset.Delete.  I would imagine you can't delete feature datasets unless they are empty though.
0 Kudos
TaiBui
by
Occasional Contributor II
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
Regular Contributor III
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
Frequent Contributor III
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