I have two layers where I need to change the dataSources using buttonClick. I'm currently using the code below, but I'm unable to change the dataSource of one of the layers because the SDE database does not contain the feature class with that name.
I'm using " Dataset = featureLayer.Name.Split('.').ToList().Last()" where it is looking for the exact name, but I need to match the data by its field rather than by its name Is there a way to do this, and if so, could someone please provide a code snippet?
return QueuedTask.Run(() =>
CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();
string connection = System.IO.Path.GetFullPath(catalogPath);
string suffix = System.IO.Path.GetExtension(connection).ToLower();
var workspaceConnectionString = string.Empty;
WorkspaceFactory wf = WorkspaceFactory.FileGDB;
if (suffix == ".sde")
wf = WorkspaceFactory.SDE;
var dbGdbConnection = new DatabaseConnectionFile(new Uri(connection, UriKind.Absolute));
workspaceConnectionString = new Geodatabase(dbGdbConnection).GetConnectionString();
CIMStandardDataConnection updatedDataConnection = new CIMStandardDataConnection()
WorkspaceConnectionString = workspaceConnectionString,
WorkspaceFactory = wf,
DatasetType = esriDatasetType.esriDTFeatureClass,
Dataset = featureLayer.Name.Split('.').ToList().Last()
Error which I'm getting because of Name
Thanks in advance!
Can you give me an example of what you mean by "I need to match the data by its field rather than by its name"?
For example, when I run the above code, it searches DBMS for the name 'NEW_PODS.VCAP.ROUTENAME'.
Instead, in the database, it's by the name 'NEW_PODS.ASSET.ROUTENAME,' and that's the reason I'm getting the DBMS table not found error.
So according to me its mapping by the Name but is it possible we can do the mapping by its fields name or by any other attributes?