Select to view content in your preferred language

ICursor with Single Table problem

2248
3
Jump to solution
07-18-2012 06:05 AM
DaveCouture
Occasional Contributor
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

0 Kudos
1 Solution

Accepted Solutions
NeilClemmons
Honored Contributor
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

0 Kudos
3 Replies
LeoDonahue
Deactivated User
If you are using a StandaloneTable, then ICursor has nextRow to iterate over the StandaloneTable.
0 Kudos
NeilClemmons
Honored Contributor
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.
0 Kudos
DaveCouture
Occasional Contributor
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

0 Kudos