laptop and a wrench

Bug

AddJoin gives error when joining a SqlServer table with no ObjectID.

Last Published: August 25, 2014 ArcGIS for Desktop
Bug ID Number NIM039018
SubmittedOctober 3, 2008
Last ModifiedJune 5, 2024
Applies toArcGIS for Desktop
Version found9.3
Operating SystemWindows OS
Operating System VersionXP
StatusDuplicate

Additional Information

Duplicate of NIM038601

Workaround

Use ArcObjects code IMemoryRelationshipClassFactory & IDisplayRelationshipClassSee sample below.Public Sub joinATable() On Error GoTo EH Dim pDoc As IMxDocument Dim pMap As IMap Set pDoc = ThisDocument Set pMap = pDoc.FocusMap ' Get the first layer in the table on contents Dim pFeatLayer As IFeatureLayer Dim pDispTable As IDisplayTable Dim pFCLayer As IFeatureClass Dim pTLayer As ITable If pMap.LayerCount = 0 Then MsgBox "Must have at least one layer" Exit Sub End If Set pFeatLayer = pMap.Layer(0) Set pDispTable = pFeatLayer Set pFCLayer = pDispTable.DisplayTable Set pTLayer = pFCLayer ' Get the first table in the table on contents Dim pTabCollection As IStandaloneTableCollection Dim pStTable As IStandaloneTable Dim pDispTable2 As IDisplayTable Dim pTTable As ITable Set pTabCollection = pMap If pTabCollection.StandaloneTableCount = 0 Then MsgBox "Must have atleast one table" Exit Sub End If Set pStTable = pTabCollection.StandaloneTable(0) Set pDispTable2 = pStTable Set pTTable = pDispTable2.DisplayTable ' Create virtual relate Dim pMemRelFact As IMemoryRelationshipClassFactory Dim pRelClass As IRelationshipClass Set pMemRelFact = New MemoryRelationshipClassFactoryDim strJoiningFieldinTable As StringDim strJoiningFIeldinFeatureClass As StringstrJoiningFieldinTable = "inty"strJoiningFIeldinFeatureClass = "Fid" Set pRelClass = pMemRelFact.Open("TabletoLayer", pTTable, strJoiningFieldinTable, pTLayer, _ strJoiningFIeldinFeatureClass, "forward", "backward", esriRelCardinalityOneToOne) ' use Relate to perform a join Dim pDispRC As IDisplayRelationshipClass Set pDispRC = pFeatLayer pDispRC.DisplayRelationshipClass pRelClass, esriLeftOuterJoin MsgBox ("done") Exit SubEH: MsgBox Err.Number & " " & Err.Description End Sub

Steps to Reproduce

Bug ID: NIM039018

Software:

  • ArcGIS for Desktop

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options