![]() ![]() |
ESRI.ArcGIS.ADF.IMS | |
StoredQuery Class | |
Members Example See Also Send Feedback |
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace : StoredQuery Class |

Visual Basic (Declaration) | |
---|---|
<SerializableAttribute()> Public Class StoredQuery |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As StoredQuery |
C# | |
---|---|
[SerializableAttribute()] public class StoredQuery |
In an application, error checking should be performed, and the user's input should be checked for malicious content.
C# | ![]() |
---|---|
FeatureLayer theLayer = (FeatureLayer)mapView.Layers.FindByName("Cities"); StoredQueryCollection storedQueryColl = theLayer.StoredQueries; // Find the StoredQuery with Population in the name StoredQuery popQuery = null; foreach (StoredQuery sq in storedQueryColl) { if (sq.Name.IndexOf("Population") > -1) popQuery = sq; } if (popQuery != null) { string sqWhere = popQuery.WhereExpression; string sqVar = popQuery.Variable.Name; // Replace the variable with the value entered by the user string whereExp = sqWhere.Replace(sqVar, TextBox1.Text); // Use the where expression in a query on the layer Filter queryFilter = new Filter(whereExp); QueryParameters queryParam = new QueryParameters(queryFilter); FeatureTable queryResults = theLayer.Query(queryParam); // Display any results in a GridView control if (queryResults.Rows.Count > 0) { GridView1.DataSource = queryResults; GridView1.DataBind(); } } |
Visual Basic | ![]() |
---|---|
Dim theLayer As FeatureLayer = _ CType(mapView.Layers.FindByName("Cities"), FeatureLayer) Dim storedQueryColl As StoredQueryCollection = _ theLayer.StoredQueries ' Find the StoredQuery with "Population" in the name Dim popQuery As StoredQuery = Nothing For Each sq As StoredQuery In storedQueryColl If sq.Name.IndexOf("Population") > -1 Then popQuery = sq End If Next If Not IsNothing(popQuery) Then Dim sqWhere As String = popQuery.WhereExpression Dim sqVar As String = popQuery.Variable.Name ' Replace the variable with the value entered by the user Dim whereExp As String = sqWhere.Replace(sqVar, TextBox1.Text) ' Use the where expression in a query on the layer Dim queryFilter As New Filter(whereExp) Dim queryParam As New QueryParameters(queryFilter) Dim queryResults As FeatureTable = theLayer.Query(queryParam) ' Display any results in a GridView control If queryResults.Rows.Count > 0 Then GridView1.DataSource = queryResults GridView1.DataBind() End If End If |
Stored queries are queries defined by the creator of the map service and attached to the properties of the layer. They can be used to query the layer easily, since they define all but the value needed for the query.
Stored queries define only attribute queries. Spatial queries based on geometry are not supported.
Stored queries are supported with standard ArcIMS image services. They are not available with ArcMap Server image services. See the ArcIMS Help, in the ArcXML Guide, for more information on setting up stored queries.
Stored queries cannot be used directly to query the layer. Instead, you can use the properties of the stored query to set up the QueryParameters, which can then be used to query the layer. For example, the WhereExpression of the StoredQuery can be used in the WhereExpression of the Filter object in the QueryParameters.
In order to use the WhereExpression, you will need to substitute the value you want to query for the query variable in the where expression. For instance, the WhereExpression in the StoredQuery could be:
POPULATION > [var>]
In this case, the "[var]" will need to be replaced with a search value, such as 1000. The string of the variable to be replaced is given in Variable.
Only a single variable is supported for replacement purposes.
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