ArcObjects Component Help  (Core)    

RelQueryTable Example

The following code example uses a RelQueryTable to join a Table to a FeatureClass . It then prints the names of the fields in the RelQueryTable.

[Visual Basic 6.0]
Private Sub RelQryTabExample(pFCls As IFeatureClass, strFClsFld As String, pTable As ITable, strTabFld As String) ' ++ Create the MemoryRelationshipClass that defines what is to be joined Dim pMemRelClassFact As IMemoryRelationshipClassFactory Set pMemRelClassFact = New MemoryRelationshipClassFactory Dim pRelClass As IRelationshipClass Set pRelClass = pMemRelClassFact.Open("Country_Demog", pFCls, _ strFClsFld, pTable, strTabFld, "forward", "backward", esriRelCardinalityOneToMany) ' ++ Perform the join Dim pRelQueryTableFact As IRelQueryTableFactory Dim pRelQueryTab As ITable Set pRelQueryTableFact = New RelQueryTableFactory Set pRelQueryTab = pRelQueryTableFact.Open(pRelClass, True, Nothing, Nothing, "", True, True) ' ++ Print the fields Dim pCursor As ICursor Set pCursor = pRelQueryTab.Search(Nothing, True) Dim pField As IField Dim pFields As IFields Dim intI As Integer, intJ As Integer Set pFields = pCursor.Fields intI = pFields.FieldCount - 1 For intJ = 0 To intI Set pField = pFields.Field(intJ) Debug.Print pField.Name Next intJ End Sub

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.