This document is archived and information here might be outdated.  Recommended version.


IMapServer2.QueryFeatureCount Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Carto)  

IMapServer2.QueryFeatureCount Method

Returns the count of the features that meet the query filter selection criteria for the specified layer.

[Visual Basic .NET]
Public Function QueryFeatureCount ( _
    ByVal MapName As String, _
    ByVal LayerID As Integer, _
    ByVal Filter As IQueryFilter _
) As Integer
[C#]
public int QueryFeatureCount (
    string MapName,
    int LayerID,
    IQueryFilter Filter
);
[C++]
HRESULT QueryFeatureCount(
  BSTR MapName,
  long LayerID,
  IQueryFilter* Filter,
  long* Count
);
[C++]

Parameters MapName [in] MapName is a parameter of type BSTR LayerID [in] LayerID is a parameter of type long Filter [in]
Filter is a parameter of type IQueryFilter Count [out, retval] Count is a parameter of type long

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

QueryFeatureCount returns the number of map features that match the parameters of a given query filter.

QueryFeatureCount requires a number of input parameters. These include: a MapName, LayerID, and a QueryFilter. The QueryFilter can be an attribute query (SQL espression), a spatial query, or a combination of both.

QueryFilter 

QueryFilter provides the ability to query based on attribute filter (SQL expression) a spatial filter, or a combination of both. Attribute filters take any valid ‘non-GIS data specific’ SQL statement. For example, CNTRY_CODE=‘BD’ or POPULATION=12345. Syntax for querying date fields depend on the underlying data. If you are working with Shapefile or File GeoDatabase data the syntax is <FieldName>=date ‘YYYY-MM-DD’; for Access-based Personal GeoDatabase the sytax is #YYYY-MM-DD#. For SDE database, check with the specific database’s help.

SearchShape 

Geometry set in ISpatialFilter should meet the following criteria:

Miscellaneous

MaxRecordCount does not affect QueryFeatureCount or QueryFeatureCount2.

There are two key differences between Find and QueryFeatureCount. The first is that Find can work on multiple layers while the query methods work with a single layer. The second is that Find only works with a search string. The query methods use a queryFilter as a parameter. This allows the query to be based on either an attribute filter (SQL expression) or a spatial filter.

See Also

IMapServer2 Interface