JoinTabletoLayere returning different table names in 10.1

738
2
04-09-2013 02:17 PM
scottvalentine
New Contributor
After the following code is run the attribute table on the shape file to which a comma delimited text file was joined contains the field names as listed on the first line of the text file. In the exported shape file of the joined feature class and table, the field names from the joined text file now appear as qryResults,qryResul_1, qryResul_2, qryResul_3, qryResul_4 instead of the field names in the table of ACTNUM, MA_,SA_,NH_, and PIN. This worked fine in 10.0 and now in 10.1 the next function following the export that uses the field names fails. Is this the result that should be expected from this join in 101?

Thanks........Scott

Dim bolJoin As Boolean
        bolJoin = JoinTableToLayer(pGFLayer, pRTable, "PIN", "PIN")

        pFClass = pGFLayer.DisplayFeatureClass

        exportFC(pFClass, "taxlots_2")

        'pFLayer = New FeatureLayer
        'pFClass = pFWorkspace.OpenFeatureClass("taxlots_2")
        'pFLayer.FeatureClass = pFClass
        'pFLayer.Name = "taxlots_2"
        'pMap.AddLayer(pFLayer)
        'pMxDoc.UpdateContents()



        '****************************

    End Sub
    Public Function JoinTableToLayer(ByVal pFeatureLayer As IGeoFeatureLayer, _
                                     ByVal pTable As ITable, _
                                     ByVal sLayerField As String, _
                                     ByVal sTableField As String) As Boolean
        Dim pMemoryRelationshipClassFactory As IMemoryRelationshipClassFactory
        Dim pRelationshipClass As IRelationshipClass
        Dim pDisplayRelationshipClass As IDisplayRelationshipClass

        'On Error GoTo ErrorHandler

        'pMemoryRelationshipClassFactory = New MemoryRelationshipClassFactory

        pMemoryRelationshipClassFactory = New MemoryRelationshipClassFactoryClass()
        pRelationshipClass = pMemoryRelationshipClassFactory.Open("Join", pFeatureLayer.DisplayFeatureClass, sLayerField, pTable, sTableField, "forward", "backward", esriRelCardinality.esriRelCardinalityOneToOne)
        pDisplayRelationshipClass = pFeatureLayer
        On Error GoTo ErrorHandler
        pDisplayRelationshipClass.DisplayRelationshipClass(pRelationshipClass, esriJoinType.esriLeftOuterJoin)

        JoinTableToLayer = True
        Exit Function
ErrorHandler:
        'ErrorMessage "modGlobals:JoinTableToLayer()"
    End Function
0 Kudos
2 Replies
RobertBorchert
Frequent Contributor III
Does your text file contain the same column headings?  If it does it will rename them that way.

Why do it with code.  Simply perform a join manually.  it will probably not happen.


After the following code is run the attribute table on the shape file to which a comma delimited text file was joined contains the field names as listed on the first line of the text file. In the exported shape file of the joined feature class and table, the field names from the joined text file now appear as qryResults,qryResul_1, qryResul_2, qryResul_3, qryResul_4 instead of the field names in the table of ACTNUM, MA_,SA_,NH_, and PIN. This worked fine in 10.0 and now in 10.1 the next function following the export that uses the field names fails. Is this the result that should be expected from this join in 101?

Thanks........Scott

Dim bolJoin As Boolean
        bolJoin = JoinTableToLayer(pGFLayer, pRTable, "PIN", "PIN")

        pFClass = pGFLayer.DisplayFeatureClass

        exportFC(pFClass, "taxlots_2")

        'pFLayer = New FeatureLayer
        'pFClass = pFWorkspace.OpenFeatureClass("taxlots_2")
        'pFLayer.FeatureClass = pFClass
        'pFLayer.Name = "taxlots_2"
        'pMap.AddLayer(pFLayer)
        'pMxDoc.UpdateContents()



        '****************************

    End Sub
    Public Function JoinTableToLayer(ByVal pFeatureLayer As IGeoFeatureLayer, _
                                     ByVal pTable As ITable, _
                                     ByVal sLayerField As String, _
                                     ByVal sTableField As String) As Boolean
        Dim pMemoryRelationshipClassFactory As IMemoryRelationshipClassFactory
        Dim pRelationshipClass As IRelationshipClass
        Dim pDisplayRelationshipClass As IDisplayRelationshipClass

        'On Error GoTo ErrorHandler

        'pMemoryRelationshipClassFactory = New MemoryRelationshipClassFactory

        pMemoryRelationshipClassFactory = New MemoryRelationshipClassFactoryClass()
        pRelationshipClass = pMemoryRelationshipClassFactory.Open("Join", pFeatureLayer.DisplayFeatureClass, sLayerField, pTable, sTableField, "forward", "backward", esriRelCardinality.esriRelCardinalityOneToOne)
        pDisplayRelationshipClass = pFeatureLayer
        On Error GoTo ErrorHandler
        pDisplayRelationshipClass.DisplayRelationshipClass(pRelationshipClass, esriJoinType.esriLeftOuterJoin)

        JoinTableToLayer = True
        Exit Function
ErrorHandler:
        'ErrorMessage "modGlobals:JoinTableToLayer()"
    End Function
0 Kudos
scottvalentine
New Contributor
Does your text file contain the same column headings?  If it does it will rename them that way.

Why do it with code.  Simply perform a join manually.  it will probably not happen.


The text file does contain the headings ACTNUM, MA_,SA_,NH_, and PIN which are being replaced with the truncated name of the text file apppended with _1, _2, etc. This is part of a larger addin.
0 Kudos