Problem: Automation error when using the TableSort CoClass on tables in a database
The tablesort coclass can be used to return rows in a specific sort order. If this coclass is used with data that is not registered with the geodatabase, it will fail with an automation error.
An ObjectID column is required in order to sort rows with the TableSort colcass.
Solution or Workaround
Besides registering with the geodatabase, the following will also solve the problem:
- Add a long integer field to the table or use an existing one and create a unique, not null index for it. Populate the field with integer values, making sure all values are unique and no fields are empty. If this field exists, ArcMap will use it like an ObjectID field and the tablesort will succeed.
- In ArcGIS 8.3, some existing functionality has been extended to allow the creation of a table or a layer with a sub-set of columns and rows in ArcMap. These tables have ObjectID columns by default.
In ArcGIS 8.3, there is a sample for creating these tables. Go to ArcObjects Developer Help > Contents Tab > Samples > Geodatabase > Query Based Tables.