ICursor with Single Table problem

1620
3
Jump to solution
07-18-2012 06:05 AM
Highlighted
New Contributor III
I'm working with a GDB Single Table (not an attribute table) and I'm having problem with retrieving field values, because I'm not sure how to handle the ICursor, on Single Tables. I can select a Single Table in the TOC, I can perform a query and I can find out if a field exists, but I can't retrieve values. I'm missing something like feature = cursor.NextFeature., to move down the records and retreive values. But, I can't use IFeature and IFeatureCursor interfaces, because it's not an attribute table.

This is the code stripped down:




                Dim subdivisionTable As ITable = GetTable(tableName, pMap)
                Dim queryFilter As ESRI.ArcGIS.Geodatabase.IQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilterClass()
                queryFilter.WhereClause = "PID = '163922'"
                Dim cursor As ESRI.ArcGIS.Geodatabase.ICursor = subdivisionTable.Search(queryFilter, False)
                Dim panField As Integer = subdivisionTable.FindField("PAN")
            
                If panField = -1 Then
                    MsgBox("field doesn't exists")
                    Return
                Else
                    MsgBox(subdivisionTable.Value(panField))
                End If

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Regular Contributor III
You use ICursor the same way you use IFeatureCursor except for the cursor contains rows instead of features.  So, use IRow instead of IFeature.  The method calls reflect this as well, use ICursor.NextRow instead of IFeatureCursor.NextFeature.

View solution in original post

Reply
0 Kudos
3 Replies
Highlighted
Regular Contributor
If you are using a StandaloneTable, then ICursor has nextRow to iterate over the StandaloneTable.
Reply
0 Kudos
Highlighted
Regular Contributor III
You use ICursor the same way you use IFeatureCursor except for the cursor contains rows instead of features.  So, use IRow instead of IFeature.  The method calls reflect this as well, use ICursor.NextRow instead of IFeatureCursor.NextFeature.

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor III
Thanks guys, I got it to work with IRow.


               
                Dim row As IRow
                Dim subdivisionTable As ITable = GetTable(tableName, pMap)
                Dim queryFilter As ESRI.ArcGIS.Geodatabase.IQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilterClass()
                queryFilter.WhereClause = "PID = '163922'"
                Dim cursor As ESRI.ArcGIS.Geodatabase.ICursor = subdivisionTable.Search(queryFilter, False)
                Dim panField As Integer = subdivisionTable.FindField("PAN")
                row = cursor.NextRow

                If panField = -1 Then
                    MsgBox("field doesn't exists")
                    Return
                Else
                    MsgBox(row.Value(panField))
                End If

Reply
0 Kudos