ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapMember Class / SetDataConnection Method
A CIM data connection value object.
true to make sure dataset exists and of valid data type before replacing the data source e.g. you cannot change a FeatureLayer's data source to a Raster Dataset.

-or-

false to indicate no validation required. It might not already exist. This can be useful for scenarios that require data sources to be updated ahead of the data being created. Note, in these cases, the data would appear broken in the map.
Example

In This Topic
    SetDataConnection Method
    In This Topic
    Updates a MapMember's data source. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetDataConnection( 
       CIMDataConnection dataConnection,
       bool validateConnection
    )
    Public Sub SetDataConnection( _
       ByVal dataConnection As CIMDataConnection, _
       Optional ByVal validateConnection As Boolean _
    ) 

    Parameters

    dataConnection
    A CIM data connection value object.
    validateConnection
    true to make sure dataset exists and of valid data type before replacing the data source e.g. you cannot change a FeatureLayer's data source to a Raster Dataset.

    -or-

    false to indicate no validation required. It might not already exist. This can be useful for scenarios that require data sources to be updated ahead of the data being created. Note, in these cases, the data would appear broken in the map.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Reset the URL of a feature service layer
    CIMStandardDataConnection dataConnection = dataConnectionLayer.GetDataConnection() as CIMStandardDataConnection;
    dataConnection.WorkspaceConnectionString = newConnectionString;
    dataConnectionLayer.SetDataConnection(dataConnection);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also