I am using the ArcGIS Explorer SDK and have run into an issue surrounding a query I would like to perform with SQL. I believe my query is built wrong or perhaps I am looking at the wrong fields. Would anyone have any input on my code below and/or possible solutions?
I would like the code to query a column for specific values then return them into a combo box. My query simply returns a blank value at the moment. Below is the code for that block.
Try
Dim md As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
Dim map As Map = md.Map
Dim cblayernameselect As MapItem = cblayername.SelectedItem
Dim cbfieldnameselect As String = cbfieldname.SelectedItem
Dim selitem As SelectedItemsCollection = ESRI.ArcGISExplorer.Application.Application.SelectedItems
cbattribute.Items.Clear()
selitem.Select(cblayernameselect)
Dim child As PackageChildLayer = TryCast(ESRI.ArcGISExplorer.Application.Application.SelectedItems(0), PackageChildLayer)
Dim layertable As Table = child.Table
Dim cbcolumn As Column = layertable.Columns.Item(cbfieldnameselect)
Dim whereclause As String = "SELECT " & cbcolumn.Name & " FROM " & layertable.Name
Dim rows As RowCollection = layertable.Search(New Filter(whereclause))
For Each row In rows
cbattribute.Items.Add(row)
Next row
Catch ex As Exception
MsgBox(ex.Message)
End Try
Answer
Without reading all of your question I will guess the answer! You are sending a complete T-SQL 'SELECT' statement when the QueryFilter WhereClause property is just that - a where clause (what comes after the 'WHERE' keyword.) Create a QueryFilter with a valid WhereClause and populate the SubFields property with the fields you want returned.
No comments:
Post a Comment