ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMStandardDataConnection Class / WorkspaceConnectionString Property
Example

In This Topic
    WorkspaceConnectionString Property (CIMStandardDataConnection)
    In This Topic
    Gets or sets the workspace connection string.
    Syntax
    Public Property WorkspaceConnectionString As String
    public string WorkspaceConnectionString {get; set;}
    Example
    Add a WFS Service
    {
        CIMStandardDataConnection cIMStandardDataConnection = new CIMStandardDataConnection()
        {
            WorkspaceConnectionString = @"SWAPXY=TRUE;SWAPXYFILTER=FALSE;URL=http://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WFSServer;VERSION=2.0.0",
            WorkspaceFactory = WorkspaceFactory.WFS,
            Dataset = "Continent",
            DatasetType = esriDatasetType.esriDTFeatureClass
        };
    
        // Add a new layer to the map
        var layerPamsDC = new LayerCreationParams(cIMStandardDataConnection);
        //Note: Needs QueuedTask to run
        Layer layerCreated = LayerFactory.Instance.CreateLayer<FeatureLayer>(layerPamsDC, MapView.Active.Map);
    }
    Reset the URL of a feature service layer
    {
        CIMStandardDataConnection dataConnection = featureLayer.GetDataConnection() as CIMStandardDataConnection;
        dataConnection.WorkspaceConnectionString = @"DATABASE=C:\Data\USNationalParks\USNationalParks.gdb";
        //Note: needs to be called on the MCT
        featureLayer.SetDataConnection(dataConnection);
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also