ESRI.ArcGIS.ADF.IMS
Query(QueryParameters) Method
See Also  Example Send Feedback
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > FeatureLayer Class > Query Method : Query(QueryParameters) Method




queryParameters
Parameters used in the query.
Queries the FeatureLayer.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Query( _
   ByVal queryParameters As QueryParameters _
) As FeatureTable
Visual Basic (Usage)Copy Code
Dim instance As FeatureLayer
Dim queryParameters As QueryParameters
Dim value As FeatureTable
 
value = instance.Query(queryParameters)
C# 
public FeatureTable Query( 
   QueryParameters queryParameters
)

Parameters

queryParameters
Parameters used in the query.

Return Value

FeatureTable containing features found.

Example

The following example selects all cities with a population over one million that are within 500 kilometers of a specific envelope. It sets up the query filter, which includes both an attribute and a geometry filter (the envelope). It adds a buffer tolerance to the filter, which causes the selection to extend in a buffer around the geometry. It uses the filter in a QueryParameters, which is used to perform the query. If any features are found, they are displayed in a GridView control. The code below assumes an existing MapView object.

For an example of selecting features with a buffer and target layer, see SelectionBuffer.

C#Copy Code
// Get a reference to the query layer
FeatureLayer theLayer =
    (FeatureLayer)mapView.Layers.FindByName("Cities");
 
// Set up the filter with the criteria for the query
// -- includes spatial and attribute filters
Filter queryFilter = new Filter();
queryFilter.WhereExpression = "POPULATION > 1000000";
queryFilter.Geometry = new Envelope(20, 40, 25, 45);
// Buffer the envelope filter
queryFilter.Tolerance = 500.0;
queryFilter.ToleranceUnits = BufferUnits.Kilometers;
 
QueryParameters queryParams = new QueryParameters(queryFilter);
 
// Perform the query and return a FeatureTable
FeatureTable queryResultsTable = theLayer.Query(queryParams);
 
// If any features found, display them in a GridView control
if (queryResultsTable.Rows.Count > 0)
{
    GridView1.DataSource = queryResultsTable;
    GridView1.DataBind();
}
else
{
    Label1.Text = "No features found.";
}
Visual BasicCopy Code
' Get a reference to the query layer
Dim theLayer As FeatureLayer = _
    CType(mapView.Layers.FindByName("Cities"), FeatureLayer)
 
' Set up the filter with the criteria for the query
' -- includes spatial and attribute filters
Dim queryFilter As New Filter()
queryFilter.WhereExpression = "POPULATION > 1000000"
queryFilter.Geometry = New Envelope(20, 40, 25, 45)
' Buffer the envelope filter
queryFilter.Tolerance = 500.0
queryFilter.ToleranceUnits = BufferUnits.Kilometers
 
Dim queryParams As New QueryParameters(queryFilter)
 
' Perform the query and return a FeatureTable
Dim queryResultsTable As FeatureTable 
queryResultsTable = theLayer.Query(queryParams)
 
' If any features found, display them in a GridView control
If queryResultsTable.Rows.Count > 0 Then
 
    GridView1.DataSource = queryResultsTable
    GridView1.DataBind()
 
Else
    Label1.Text = "No features found."
End If

Remarks

Use this method to obtain information about features in the map. Layers can be queried by attributes, by geometry, or both.

Dynamic layers can also be queried. Dynamic layers can be added for standard image services. They are not supported for ArcMap Server image services.

This method returns a FeatureTable. Since a FeatureTable inherits from System.Data.DataTable, it can be used as the data source for data-bound controls that accept a DataTable, such as the the GridView control or DetailsView control. This can make it simple to display the results of a query or identify operation.

If many features may be returned from the query, you can retrieve a limited number in a single query, then repeat the query to retrieve additional records. This may be a convenient way to display pages of records to users. To use this approach, limit the records returned with QueryParameters.FeatureLimit. Then check the FeatureTable returned for FeatureTable.HasMore. If true, then you can retrieve additional records by using the Query(QueryParameters, int) method, setting the beginRecord parameter to one higher than the number of records already retrieved.

Note that the ArcIMS server may limit the number of features returned from queries. The default is 2000 features, but this can be modified by the server administrator. See the topic "Strategies for using feature limits" in ArcIMS Help for details.

If no features are found, the method returns a DataTable with no rows. Check the DataTable's Rows.Count property to see whether any features are found.

This method may throw an exception if the field(s) in the where expression in the filter do not exist.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2011 All Rights Reserved.