Select to view content in your preferred language

VB.NET WhereClause table/Field

1065
3
01-22-2021 05:47 AM
SigurdurGesr
Emerging Contributor

 

Hi

how can I get data from table/Field  = EXTRA.House   / number

 

 

   Public Sub search_address()
    
        Dim pMap As IMap
        Dim pMxDoc As IMxDocument
        Dim pFeatLayer As IFeatureLayer
        Dim pFeatSel As IFeatureSelection
        Dim pQueryFilter As IQueryFilter
        pMxDoc = CType(My.ArcMap.Application.Document, IMxDocument)
        pMap = pMxDoc.FocusMap
    
        Dim sLayerName As String       
        sLayerName = Layer_address
        Dim i As Integer
        For i = 0 To pMap.LayerCount - 1
            If pMap.Layer(i).Name = sLayerName Then
                pFeatLayer = pMap.Layer(i)
                Exit For
            End If
        Next i
  
        If pFeatLayer Is Nothing Then
            MsgBox(Layer_address & " Error")
            Exit Sub
        End If


   
        pQueryFilter = New QueryFilter
      
        pQueryFilter.WhereClause = "HEI1 in (select HEI1 from EXTRA.House where number = 2502163)"


        Dim pFeaCursor As IFeatureCursor = pFeatLayer.Search(pQueryFilter, False)
        Dim pFeature As IFeature = pFeaCursor.NextFeature
        Do Until pFeature Is Nothing
            Dim index As Integer = pFeature.Fields.FindField("STREETNAMECODE") 'O(n) 
            Dim sName As String = pFeature.Value(index)

            Dim newItem As New ListViewItem(pFeature.OID)

                If IsDBNull(pFeature.Value(pFeature.Fields.FindField("POSTALCODE"))) = False Then
                    newItem.SubItems.Add(pFeature.Value(pFeature.Fields.FindField("POSTALCODE")))
                Else
                    newItem.SubItems.Add("")
                End If

                If IsDBNull(pFeature.Value(pFeature.Fields.FindField("STREETNAME"))) = False Then
                    newItem.SubItems.Add(pFeature.Value(pFeature.Fields.FindField("STREETNAME")))
                Else
                    newItem.SubItems.Add("")
                End If

                Listv_search.Items.Add(newItem)
            pFeature = pFeaCursor.NextFeature
        Loop

 

Tags (1)
0 Kudos
3 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Here is your problem:

        pQueryFilter.WhereClause = "HEI1 in (select HEI1 from EXTRA.House where number = 2502163)"

You need to add to WhereClause only where section of your query:

        pQueryFilter.WhereClause = "number = 2502163"
0 Kudos
SigurdurGesr
Emerging Contributor

 

I can get record from pFeatLayer but I can not get record from EXTRA.House

pQueryFilter.WhereClause = "HEI1 in (select HEI1 from EXTRA.House where number = 2502163)"
		

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

What is your backend data source, RDBMS, FGDB, etc...?  I assume you are getting an error, what exactly is the error message?

0 Kudos