Hi everyoneI got query layers in a map document which point to sql server databases. I'm trying to find a way to change the database at which the query layer is pointing to. When assigning the new sqlWorkspace (with new connection properties) to an existing query layer an exception is raised saying "featureclass already exists". Some snippets of my code:
IWorkspace workspace = workspaceFactory.Open(connectionProps, 0);
ISqlWorkspace sqlWorkspace = (ISqlWorkspace)workspace;
IQueryDescription desc = sqlWorkspace.GetQueryDescription("select * from " + tblName);
ITable queryClass = sqlWorkspace.OpenQueryClass("MyQuery", desc);
IFeatureClass fc = (IFeatureClass)queryClass;
//assign the new fc to an existing map layer, this is where the exception happens
mapLayer.FeatureClass = fc;
how can i change the sql workspace of a map layer programmatically?