I'm creating a query table with IQueryDef and then using MemoryRelationshipClassFactory to create an inner join between a feature layer and the query table. Both the query table and the join are created without incident and work correctly in ArcMap, (only the features with matching records in the query table are displayed on the map). However, when I attempt to open the attribute table for the feature layer in ArcMap I get the following error:

Could not load data from the data source. If you can correct the problem, press the refresh button to reload data. Possible problems can include bad network connection, invalid field, etc. Field is not editable.

The table then opens with empty rows. I'm not sure what the "Field is not editable" message is telling me. I thought perhaps there was something wrong with the query table, but I can create the table and add it to ArcMap as a stand alone table and it opens correctly. It seems there is something in the way I am doing the join that is causing trouble with the feature layers Display Table.

Below is the relevant code:

    Dim qd As IQueryDef = ftrWksp.CreateQueryDef
    qd.Tables = "swCBCleaning"
    qd.SubFields = "*"
    qd.WhereClause = pre & "CompletedDate" & suf & " >= date '2012-11-08 00:00:00'"

    Dim qn2 As IQueryName2 = CType(New TableQueryName, IQueryName2)
    qn2.QueryDef = qd
    qn2.PrimaryKey = "swCBCleaning.OBJECTID"
    qn2.CopyLocally = False
    Dim dsName As IDatasetName = CType(qn2, IDatasetName)
    Dim dataSet As IDataset = CType(ds.Workspace, IDataset)
    dsName.WorkspaceName = CType(dataSet.FullName, IWorkspaceName)
    dsName.Name = "swCBCleaning"
    Dim name As IName = CType(qn2, IName)
    Dim tblJoin As ITable = CType(name.Open, ITable)

    Dim memRelClassFactoryType As Type = Type.GetTypeFromProgID("esriGeodatabase.MemoryRelationshipClassFactory")
    Dim memRelClassFactory As IMemoryRelationshipClassFactory = CType(Activator.CreateInstance(memRelClassFactoryType), IMemoryRelationshipClassFactory)

    Dim relClass As IRelationshipClass
    Dim dispRelClass As IDisplayRelationshipClass

    relClass = memRelClassFactory.Open("Join", geoFtrLayer.DisplayFeatureClass, "GlobalID", CType(tblJoin, IObjectClass), "FeatureGlobalID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany)
    dispRelClass = CType(geoFtrLayer, IDisplayRelationshipClass)
    dispRelClass.DisplayRelationshipClass(relClass, esriJoinType.esriLeftInnerJoin)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.