I use summary statistics GP tool to extract the max OBJECTID from a feature layer. After that I use arcpy SerachCursor to get the OBJECTID value from the statistics, but the result returned is not an integer.

The statistics contents:

enter image description here

The result of SearchCursor:

enter image description here

The python code:

import arcpy

arcpy.env.workspace = "C:/Users/lyao/Documents/ArcGIS/Default.gdb"
feature = "C:/Users/lyao/Documents/ArcGIS/Default.gdb/BQ_Segment_1_Statistics1"

with arcpy.da.SearchCursor(feature, ("MAX_geri_db_DBO_BQ_Segment_1_OBJECTID",), '"OBJECTID" = 1') as cursor:
for row in cursor:
    print str(row[0]) 

I want to know:

  1. How to get the exact same OBJECTID as in the statistics.

  2. I am using vb.net, so I want to know how to return the result to vb.net.

I am using arcmap 10.2.

  • It should be an integer, you're making it a string to print it. How would you return that to vb? Wouldn't you skip the python and read the table as ITable in vb.net? Commented Sep 18, 2014 at 2:35
  • Hi Michael, thanks for the quick reply. In fact my application is developed in vb.net, I have no idea what to do in vb.net that is the same as search cursor in arcpy.
    – ppLily
    Commented Sep 18, 2014 at 2:38
  • do you have the Esri SDK installed? Commented Sep 18, 2014 at 2:39
  • yes I have arcObjects sdk installed.
    – ppLily
    Commented Sep 18, 2014 at 2:40
  • There's a lot more to it, but I'll put something together as a sample. Will this be an add-in? Commented Sep 18, 2014 at 2:41

1 Answer 1


In VB.net:

Dim pWSF As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactory()
Dim pWS As ESRI.ArcGIS.Geodatabase.IWorkspace = pWSF.OpenFromFile("C:/Users/lyao/Documents/ArcGIS/Default.gdb", 0)
Dim pFws As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace = CType(pWS, ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)
Dim pTable As ESRI.ArcGIS.Geodatabase.ITable = pFws.OpenTable("BQ_Segment_1_Statistics1")
Dim pCur As ESRI.ArcGIS.Geodatabase.ICursor = pTable.Search(Nothing, False) ' open the cursor
Dim pRow As ESRI.ArcGIS.Geodatabase.IRow = pCur.NextRow ' first row
Dim pValue As Integer = pRow.Value(2)   ' the value in the 3rd column 

That is assuming that the table never deviates from the format shown.

You start with an IWorkspaceFactory (set the type to match the database) from which you create an IWorkspace which gets changed into a IFeatureWorkspace which is able to open the table. With the table start the cursor, get the first row and then retrieve the value.

You can see why arcpy is so popular... The online help will give some explanation and options for the objects shown but that's the way to open a table from scratch.

  • Hi Michael, is there a way of mapping values of different fields in an attribute table? I will open a new question for it.
    – ppLily
    Commented Sep 18, 2014 at 3:38
  • I think it would be best posted as another question. I would need more information on what you're trying to achieve to provide the correct guidance. Commented Sep 18, 2014 at 3:40
  • Hi Michael, the new question is gis.stackexchange.com/questions/114251/…, please check whether the information is enough.
    – ppLily
    Commented Sep 18, 2014 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.