none
whereclause格式 RRS feed

  • 问题

  •         str2 = TextBox1.Text
            pActiveView = Form1.AxMapControl1.Map
            pMap = Form1.AxMapControl1.Map
            pQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilter
            If pMap.LayerCount = 0 Then Exit Sub '如果活动图层为空 则退出sub
            'pQueryFilter.SubFields = "ID" '获取text1的输入的字段名为查询字段名
            pQueryFilter.WhereClause = "ID='" + str2 + "'"
            'pQueryFilterDefinition = pQueryFilter
            'pQueryFilterDefinition.PostfixClause = "ORDER BY str2"
            Dim i As Integer
            For i = 0 To (pMap.LayerCount - 1)
                pFeatureLayer = pMap.Layer(i)
                If pFeatureLayer.Selectable Then
                    pFeatureClass = pFeatureLayer.FeatureClass
                    'pFeatureCursor = pFeatureClass.Search(pQueryFilter, False)
                    'pFeature = pFeatureCursor.NextFeature  'Get the first feature
                    'l = pFeatureCursor.FindField(str1) '获取text1文本字段对应的索引值
                    If Not pFeature Is Nothing Then
                        textBox2.Text = pFeature.Value(2) '显示被选要素l索引值对应的字段值
                        textBox3.Text = pFeature.Value(3)
                        Exit For
                    End If
                End If
            Next i
            If pFeature Is Nothing Then
                MsgBox("没有找到符合条件的要素,请重新输入查询条件!")
            End If

    出错 请问是whereclause格式问题吗?应该怎么改呢?

    2010年12月27日 9:24

答案

  • Hello twylav,

    Welcome to MSDN Forum.

     请问具体报什么错呢?可否详细的说明一下呢?

    或许你可以把 pQueryFilter.WhereClause = "ID='" + str2 + "' 改成这样试试:pQueryFilter.WhereClause = "ID='" & str2 & "'

     

    Best Regards

    Rocky

    2010年12月29日 1:57