AnsweredAssumed Answered

queryFilter Count

Question asked by davecouture on Jun 19, 2012
Latest reply on Jun 19, 2012 by davecouture
I'm trying to add a count to a Query, so I can pop a message if the count = 0 (didn't find the record). This is what I have:

Public Sub SelectMapFeaturesByAttributeQuery(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer, ByVal whereClause As System.String)

        If activeView Is Nothing OrElse featureLayer Is Nothing OrElse whereClause Is Nothing Then
            Return
        End If

        Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast

        ' Set up the query
        Dim queryFilter As IQueryFilter = New QueryFilterClass
        queryFilter.WhereClause = whereClause

        ' Invalidate only the selection cache. Flag the original selection
        activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)

        ' Perform the selection
        featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)

      
        ' Perform query count
        Dim value As Integer = 0
        value = featureLayer.GetFeatureCount(queryFilter)

        If value = 0 Then
            MsgBox("can't find PID")
        End If


        ' Flag the new selection
        activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)


    End Sub

Outcomes