"Table was not found" exception

619
2
Jump to solution
01-29-2013 05:17 PM
IlyaSolovyev
New Contributor II
ArcGIS for Desktop 10.1 SP1
ArcObjects .NET SP1
Windows 8 (russian)
Visual Studio 2010

When I try to open feature class with russian symbols (e.g. "????????_???????") from file geodatabase programmatically (fws.OpenFeatureClass(name)), I get an "Table was not found" exception. Also I tried to open feature class with name in uppercase - same result.

Any ideas?
0 Kudos
1 Solution

Accepted Solutions
MarcinDruzgala
Occasional Contributor
ArcGIS for Desktop 10.1 SP1
ArcObjects .NET SP1
Windows 8 (russian)
Visual Studio 2010

When I try to open feature class with russian symbols (e.g. "????????_???????") from file geodatabase programmatically (fws.OpenFeatureClass(name)), I get an "Table was not found" exception. Also I tried to open feature class with name in uppercase - same result.

Any ideas?


Well I suggest you to list all feature classes that are in the specified dataset and then use OpenFeatureClass method.
public List<string> listFeatClassInDataBase(Geoprocessor GP, string GDBPath , string Dataset) {      //lista      List<string> list = new List<string>();      GP.SetEnvironmentValue("workspace", @GDBPath);       IGpEnumList fcs = GP.ListFeatureClasses("*", "", Dataset);      string fc = fcs.Next();        while (fc != "")       {            list.Add(fc);            fc = fcs.Next();        }        return list; }  private void SomeMethod() {  List<string> featureClassList = listFeatClassInDataBase(GP,GDBPath, datasetName);   foreach (string feature in featureClassList)   {   if(feature == "????????_???????")   {    featWorkspace.OpenFeatureClass(feature);   }  } }


More about listing data

Debugg this and check what's your feature classes names, maybe there is a problem with russian symbols.

Regards
MDruzgala

View solution in original post

0 Kudos
2 Replies
MarcinDruzgala
Occasional Contributor
ArcGIS for Desktop 10.1 SP1
ArcObjects .NET SP1
Windows 8 (russian)
Visual Studio 2010

When I try to open feature class with russian symbols (e.g. "????????_???????") from file geodatabase programmatically (fws.OpenFeatureClass(name)), I get an "Table was not found" exception. Also I tried to open feature class with name in uppercase - same result.

Any ideas?


Well I suggest you to list all feature classes that are in the specified dataset and then use OpenFeatureClass method.
public List<string> listFeatClassInDataBase(Geoprocessor GP, string GDBPath , string Dataset) {      //lista      List<string> list = new List<string>();      GP.SetEnvironmentValue("workspace", @GDBPath);       IGpEnumList fcs = GP.ListFeatureClasses("*", "", Dataset);      string fc = fcs.Next();        while (fc != "")       {            list.Add(fc);            fc = fcs.Next();        }        return list; }  private void SomeMethod() {  List<string> featureClassList = listFeatClassInDataBase(GP,GDBPath, datasetName);   foreach (string feature in featureClassList)   {   if(feature == "????????_???????")   {    featWorkspace.OpenFeatureClass(feature);   }  } }


More about listing data

Debugg this and check what's your feature classes names, maybe there is a problem with russian symbols.

Regards
MDruzgala
0 Kudos
IlyaSolovyev
New Contributor II
Your solution works fine, thanks.

But why does my implementation lead to such a strange behaviour of FeatureWorkspace?
        public List<string> GetAllFeatureClassNames()
        {
            List<string> names = new List<string>();

            // Featureclasses in datase
            IEnumDatasetName enumDSNames = (_featureWorkspace as IWorkspace).get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            IDatasetName dsName = null;
            while ((dsName = enumDSNames.Next()) != null)
            {
                IEnumDatasetName dsFCNames = dsName.SubsetNames;
                if (dsFCNames != null)
                {
                    IDatasetName dsFCName = null;
                    while ((dsFCName = dsFCNames.Next()) != null)
                    {
                        if (dsFCName.Type == esriDatasetType.esriDTFeatureClass)
                            names.Add(dsFCName.Name);
                    }
                }
            }

            // Featureclasses in root
            IEnumDatasetName enumFCNames = (_featureWorkspace as IWorkspace).get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            IDatasetName fcName = null;
            while ((fcName = enumFCNames.Next()) != null)
            {
                names.Add(fcName.Name);
            }

            return names;
        }
0 Kudos