Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 {
share|improve this question
Did you make any progress on this one? I am getting the same problem in a personal geodatabase. – SagebrushGIS Nov 15 '12 at 22:02
Also see code here – Kirk Kuykendall Feb 14 '13 at 20:29

Use esriDTAny instead of esriDTFeatureDataset for all dataset types.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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