Return Value
The Connector associated with the currently opened data store.
| Exception | Description |
|---|---|
| System.InvalidOperationException | No valid data store has been opened prior to invoking this operation. |
| ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
Layer selectedLayer = MapView.Active.GetSelectedLayers()[0]; if (selectedLayer is FeatureLayer) { FeatureLayer featureLayer = selectedLayer as FeatureLayer; using (Table table = featureLayer.GetTable()) using (Datastore datastore = table.GetDatastore()) { ServiceConnectionProperties serviceConnectionProperties = datastore.GetConnector() as ServiceConnectionProperties; if (serviceConnectionProperties == null) return; Uri url = serviceConnectionProperties.URL; // Will be the URL to the Feature Service. string user = serviceConnectionProperties.User; // The username property will only be // populated for feature service hosted // on non-federated ArcGIS Server. string password = serviceConnectionProperties.Password; // Will always be empty. } }
Target Platforms: Windows 11, Windows 10