Hi, how do I obtain the data source of a feature layer in a map document, see pic below.
I tried to use...
IDataLayer2.DataSourceName.NameString
But it seems like DataSourceName is a COM object.
DataSourceName is described here...
http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//001200000380000000
It seems like it should just work.
Suggestions?
Solved! Go to Solution.
The datasource for a feature layer can be queried directly from the FeatureClass property:
IFeatureLayer featureLayer = ...
IFeatureClass featureClass = featureLayer.FeatureClass;
IWorkspace workspace = ((IDataset)featureClass).Workspace;
there's IMHO no need to evalute the IDataLayer2.DataSourceName property explicitly unless you need some more information about the datasource:
var dataSourceName = dataLayer.DataSourceName as IDatasetName;
ISQLSyntax sqlSyntax = (ISQLSyntax)workspace;
string tableName;
string dbName;
string ownerName;
sqlSyntax.ParseTableName(dataSourceName .Name, out dbName, out ownerName, out tableName);
The datasource for a feature layer can be queried directly from the FeatureClass property:
IFeatureLayer featureLayer = ...
IFeatureClass featureClass = featureLayer.FeatureClass;
IWorkspace workspace = ((IDataset)featureClass).Workspace;
there's IMHO no need to evalute the IDataLayer2.DataSourceName property explicitly unless you need some more information about the datasource:
var dataSourceName = dataLayer.DataSourceName as IDatasetName;
ISQLSyntax sqlSyntax = (ISQLSyntax)workspace;
string tableName;
string dbName;
string ownerName;
sqlSyntax.ParseTableName(dataSourceName .Name, out dbName, out ownerName, out tableName);
Thank you very much