I have code that gets all the Feature Datasets in a database in order to loop through them and find the one I want. This code returns 2 datasets of 24 in an SDE 9.2 database, but 3 datasets of 24 in a version 10 SP 2 database. The user has at least select permissions on all 24 of them, but the code only returns certain ones (and different ones). The code is very simple, shown below. What the heck is going on?

        ESRI.ArcGIS.Geodatabase.IWorkspace _ws = (ESRI.ArcGIS.Geodatabase.IWorkspace)aWorkspaceEdit;
        ESRI.ArcGIS.Geodatabase.IEnumDataset _ed = _ws.get_Datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureDataset);
        ESRI.ArcGIS.Geodatabase.IDataset _ds = null;
        while ((_ds = _ed.Next()) != null) {
            if (_ds.BrowseName == _datasetName) {
                ESRI.ArcGIS.Geodatabase.IEnumDataset _dsed = _ds.Subsets;
                ESRI.ArcGIS.Geodatabase.IDataset _dsfc = null;
                while ((_dsfc = _dsed.Next()) != null) {
                    if (_dsfc.BrowseName == aFeatureClassName) {
                        _fc = (ESRI.ArcGIS.Geodatabase.IFeatureClass)_dsfc;
            if (_fc == null) {
                _ds = _ed.Next();
            } else {

2 Answers 2


Use esriDTAny instead of esriDTFeatureDataset for all dataset types.


I found a workaround to the problem. Instead of doing something like this:

IEnumDataset enumDS = ws.get_Datasets(esriDatasetType.esriDTFeatureDataset);
IFeatureDataset fds = enumDS.Next() as IFeatureDataset;

Use the get_DatasetNames to get the IName implementation of an object, then convert the IName into a full fledged object.

IEnumDatasetName enumDS = ws.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IFeatureDataset fds = (enumDS.Next() as IName).Open() as IFeatureDataset;

This does not completely answer your question on why get_Datasets does not work as advertised, but this should get you the results you are after. I was having the same problem with a personal geodatabase, where the result sets were inconsistent and this solved the problem.

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.