ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Core.Data Namespace / Datastore Class / GetConnector Method
Example

In This Topic
    GetConnector Method (Datastore)
    In This Topic
    Gets the Connector associated with the currently opened data store. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public abstract Connector GetConnector()
    Public MustOverride Function GetConnector() As Connector

    Return Value

    The Connector associated with the currently opened data store.
    Exceptions
    ExceptionDescription
    No valid data store has been opened prior to invoking this operation.
    A geodatabase-related exception has occurred.
    Example
    Get the Data Connection Properties from a Feature Service
    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.
        }
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also