I need to calculate total count of distinct values of a field . That field contains many duplicate values also. The table which contains that field is stored in pgdb. I want things done in vb .net. Any help is appreciated.


If you are using ArcObjects, you would do this by IDataStatistics and IStatisticsResults

A 9.3 Example is here.

If you are using a personal geodatabase (which uses MS Access), you could use ADO and do a SELECT DISTINCT <fieldname> FROM <TableName> You can search SO for this info: https://stackoverflow.com/search?q=%5Bms-access%5D+votes%3A5+ADO+SELECT+DISTINCT

| improve this answer | |
  • Unable to cast object of type 'System.Runtime.InteropServices.CustomMarshalers.EnumeratorViewOfEnumVariant' to type 'ESRI.ArcGIS.esriSystem.IEnumVariantSimple'. Above error is showing when i use the code from 9.3 example.enumVar = CType(dataStats.UniqueValues, IEnumVariantSimple) .However i did it using Hashset.Thanks Jay for help. – Navish Aug 30 '12 at 9:58
  • Dim datastats As IDataStatistics datastats = New ESRI.ArcGIS.Geodatabase.DataStatisticsClass datastats.Field = "IPID" datastats.Cursor = pCursor Dim enumerator As IEnumerator enumerator = datastats.UniqueValues enumerator.Reset() Do While (enumerator.MoveNext()) Dim myobject As Object myobject = enumerator.Current i = i + 1 Loop – Navish Aug 31 '12 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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