AnsweredAssumed Answered

How to change programmatically the data source (FeatureClass-property) of IFeatureLayer with DataSourceType = "Query Feature Class" in ArcMap 10.3 ?

Question asked by Thomas.Koch on Mar 16, 2016
Latest reply on Sep 28, 2016 by oDarthVador

Hi all,

I have a Feature-Layer pointing to an Oracle Table (user-maintained rowid) with spatial type "SDO_GEOMETRY". The Oracle Table is not SDE-registered. By both loading the table from ArcCatalog into ArcMap or using ArcTool MakeQueryLayer I get a layer with data type "Query Feature Class".

 

Map operations e.g. zooming, panning, selecting etc. work.

My issue is changing the data source programmatically (c#, ArcMap 10.3) either results to exceptions or a layer with data type "Feature Class" and consecutively drawing errors in ArcMap when loading additional layers and executing map operations e.g. zooming, panning, selecting etc:

 

 

Drawing errors also occur when I create this layer by ArcTool MakeFeatureLayer although when loaded stand-alone, i.e. no additional layer are load in TOC, map operations e.g. zooming, panning, selecting etc. work without any errors.

 

Input: IFeatureWorkspace featureWS (cast from IWorkspace with Type = esriRemoteDatabaseWorkspace)

Input: IFeatureLayer pFeatureLayer

  • DataSourceType: Query Feature Class
  • FeatureClass: with AliasName "schema1.%Table1" (what does the character "%" mean ?? / where does this character come from ?? My table's name is "schema1.Table1" !!)

 

#region Alternative 1: IQueryDef => System.Runtime.InteropServices.COMException (0x80050140): Abstract Data Types not supported

IQueryDef queryDef = featureWS.CreateQueryDef();

queryDef.Tables = "schema1.Table1";

queryDef.SubFields = "*";

queryDef.WhereClause = string.Empty;

IFeatureDataset pFeatureQuery =

    featureWS.OpenFeatureQuery("Table1", queryDef);

pFeatureLayer.FeatureClass = pFeatureQuery as IFeatureClass;

#endregion

 

#region Alternative 2: ITable zu IDataset => Data Source Type = FeatureClass => Drawing Error in ArcMap

ITable table = featureWS.OpenTable("schema1.Table1");

IDataset dataSet = table as IDataset;

pFeatureLayer.FeatureClass = dataSet as IFeatureClass;

pFeatureLayer.DataSourceType = "Query Feature Class";

#endregion

 

So my question is how to change programmatically the data source (FeatureClass-property) of IFeatureLayer with DataSourceType = "Query Feature Class" in ArcMap 10.3 avoiding the change of DataSourceType, any exceptions and drawing errors ?

Any help is appreciated !

Outcomes