This only appears to be an issue with Personal Geodatabases (MS Access back end)... I need to search within an existing selection set to populate an ICursor. My main objective is to test whether my IQueryFilter retrieves more that one record but there is no count property over the ISelectionSet using a QueryFilter just like there is over a feature class (IFeatureCLass:FeatureCount(IQueryFilter). So in order to test whether my QueryFilter retrieves more than one record inside a selection set I am having to use the Search method pFeatureSelection.SelectionSet.Search(pQueryFilter, True, selCursor) using recycling cursor for speed then advancing to next row and again to next row to find out whether more that one row has been retrieved using my QueryFilter. (This feels awfully inefficient but works when not used over PGDB FC)

This works perfectly when used with file geodatabases and shapefiles (I customize the where clause accordingly based on the workspace type of the feature class) however when I do this over personal geodatabase the ISelectionSet:Search method fails. What is strange that it only fails after it has first succeeded many times prior. The queries I assign to the WhereClause of the query filter are very simple (i.e. "[MASTER_ID] = '56061-UNPAT-28'")

The error I am getting is "Error HRESULT E_FAIL has been returned from a call to a COM component." Err.number -2147467259

To reiterate, the very same code works fine when used with FGDB feature class and Shapefile, it's only on PGDB (Access) that it fails this way and only after it run for a while.

I ultimately need to obtain a count within a selection set that satisfies a simple query. If there is an alternate or more efficient way of doing this please share...

  • I think its a windows issue. Not sure if this will help but try this - Start > Run > dcomcnfg.exe then in the Component Service window: Component Services > Computers > Right click on My Computer > Properties > MSDTC tab > Security Configuration ... (Button) > check 'Network DTC Access' > select 'No Authentication Required' option > OK!
    – ed.hank
    Sep 21, 2015 at 14:00
  • Thanks. I don't see Security Configuration button on the MSDTC tab. Only Deafult coordinator frame with a single "Use local Coordinator" check box. I am using Win 7 Enterprise (Managed) Sep 21, 2015 at 14:06
  • The fact that it runs the first time but fails later makes me suspect you're not calling ReleaseCOMObject on something - like the cursor. Sep 21, 2015 at 14:15
  • Ah we are on Server here, let me ask the IT guru here if he knows about win 7
    – ed.hank
    Sep 21, 2015 at 14:18
  • Here are a couple of links I found, maybe they can help. forums.asp.net/t/… and codepartners.com/Blog/TabId/110/PostId/139/…
    – ed.hank
    Sep 21, 2015 at 14:21

1 Answer 1


When you're done with an ICursor or IFeatureCursor, you need to release the underlying COM object. This can be done via ReleaseCOMObject or better yet, FinalReleaseCOMObject. Do this repeatedly if you're inside a loop where you're passing the same ICursor reference repeatedly to ISelectionset.Search.

  • Don't forget also to release all the objects which implement ISet interfaces like ISelectionSet
    – Katah
    Sep 22, 2015 at 12:52
  • Thanks @VictorCatalan. I am releasing everything everything that can be released. In VB6 it was a matter of setting objects to nothing. Bad habits remain which is what caused my issue. Sep 22, 2015 at 13:14
  • I guess the next question would be when NOT to release COM via ReleaseCOMObject because I am getting some errors (5) "COM object that has been separated from its underlying RCW cannot be used" Sep 22, 2015 at 14:08
  • Don't release things you still need to use. Try it with just releasing the cursor first. Sep 23, 2015 at 5:04

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.