Opening datasets


Summary This topic discusses how to open datasets from a workspace. Specifically, it shows how to open datasets from the classic dataset model (feature classes, tables, feature datasets, and relationship classes).

About opening datasets

Given a known dataset name, the easiest way to open a dataset from a workspace is through the IFeatureWorkspace interface, which defines the following "Open" methods that require the name of an existing dataset:
The following code example shows how to open a feature class from a workspace:
[C#]
// Cast the workspace to IFeatureWorkspace and open a feature class.
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Parcels");
[VB.NET]
' Cast the workspace to IFeatureWorkspace and open a feature class.
Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace)
Dim featureClass As IFeatureClass = featureWorkspace.OpenFeatureClass("Parcels")
Note that OpenFeatureClass and OpenRelationshipClass opens both stand-alone classes and classes contained in feature datasets.


See Also:

Connecting to a geodatabase




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime