Problems with IQueryFilter and shp-File

Discussion created by dekukl on Apr 8, 2014
Latest reply on Apr 8, 2014 by dekukl

I want to get the selected features from a Layer.
tcKeyColumn= "INFOTEXT"
tcLayer= "flstkop3"

This is my Code:
    Public Function SelectMapFeatures(ByRef tcKeyColumn As String, ByRef tcLayer As String, ByRef tcObjectIDs As String, ByRef tcDataframe As String) As Boolean
        Dim loMxDoc As IMxDocument = goApp.Document
        Dim lomap As IMap = loMxDoc.FocusMap
        Dim loActiveView As IActiveView
        Dim loFeatureLayer As IFeatureLayer
        Dim loFeatureSelection As IFeatureSelection
        Dim loLayer As ILayer = lomap.Layer(0)
        Dim loQueryFilter As IQueryFilter = New QueryFilter
        Dim lcClause As String
        Dim lcObjectID As String
        Dim lcZWstring As String
        Dim lcData As String
        Dim lnSelektionAnzahl As Integer
        Dim lnUebergabeObjektAnzahl As Integer
        Dim lnNewFLSTIndex As Integer
        Dim i As Integer
        Dim j As Long
        Dim llweiter As Boolean
        Dim tlnew As Boolean

        lcData = "x"
        SelectMapFeatures = False
        lnUebergabeObjektAnzahl = occurs(tcObjectIDs, "|")
        ReDim gcObjId(lnUebergabeObjektAnzahl)
        If Not tcDataframe = "" Then
            If Not ActivateDataframe((tcDataframe)) Then
                Exit Function
            End If

        End If
        loActiveView = lomap
        For i = 0 To lomap.LayerCount - 1
            If TypeOf lomap.Layer(i) Is IGroupLayer Then
                Call Get_GroupLayerName(loMxDoc, tcLayer, loLayer)
                If Not loLayer Is Nothing Then
                    loFeatureLayer = loLayer
                    llweiter = True
                    llweiter = False
                End If
                If occurs(";" & UCase(tcLayer) & ";", ";" & UCase(GetLayerName(i)) & ";") Then
                    loFeatureLayer = lomap.Layer(i)
                    llweiter = True
                    llweiter = False
                End If
            End If
            If Not llweiter Then GoTo nexti
            tlnew = True
            lcClause = ""
            For j = 1 To lnUebergabeObjektAnzahl
                lcZWstring = token(tcObjectIDs, "|", j)
                lcObjectID = token(lcZWstring, "(", 1)
                lcClause = lcClause & Chr(91) & tcKeyColumn & Chr(93) & " = " & Chr(39) & lcObjectID & Chr(39) & " or "
            Next j
            lcClause = Left(lcClause, Len(lcClause) - 4)
            loQueryFilter.WhereClause = lcClause
            Dim pFSel As IFeatureSelection
            pFSel = loLayer
            loActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
            If tlnew Then
                    pFSel.SelectFeatures(loQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
                Catch ex As Exception
                    MsgBox("Fehler " & vbCrLf & ex.Message)
                End Try
                pFSel.SelectFeatures(loQueryFilter, esriSelectionResultEnum.esriSelectionResultAdd, False)
            End If
            tlnew = False
        Next i
       loActiveView = Nothing
        lomap = Nothing
        loMxDoc = Nothing
End Function

When the layer where I select the features is in a Geodatabase it works good. If the layer is a shp-file I get the Error "Error HRESULT E_FAIL has been returned from a call to a COM component"
The original code was VB6 for ArcGIS 9.2, now it is VB.Net Express 2010 and ArcGis 10.2. With 9.2 it worked with Geodatabases and shp-Files.
May be I posted i lttle bit to much, but I tried a lot. Please, any Help. How can I get the selected features and get the values of a specified attribut when the features are in a shp-file?