Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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;
                        break;
                    }
                }
            }
            if (_fc == null) {
                _ds = _ed.Next();
            } else {
                break;
            }
        }
        _ed.Reset();
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 gis.stackexchange.com/a/49662/59 –  Kirk Kuykendall Feb 14 '13 at 20:29
add comment

2 Answers

Use esriDTAny instead of esriDTFeatureDataset for all dataset types.

share|improve this answer
add comment

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

IEnumDataset enumDS = ws.get_Datasets(esriDatasetType.esriDTFeatureDataset);
enumDS.Reset();
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);
enumDS.Reset();
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
add comment

Your Answer

 
discard

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.