Select to view content in your preferred language

Query from mutliple Field

715
5
03-02-2011 09:37 PM
MuhammadWaqar_ul_islam
Occasional Contributor
I Want to query the DATA in different feilds of a layer
exmaple
feild1; Address = 'F.B.Area' or
feild2; Block =   'BLOCK 4' or
Feild3; Name = 'Waqar'

This Query Structure is in Arcgis server application for Query the Data

i need code for Query the data using different operation "and', "or" from different feild


thanks
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
You can update the Where property http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tasks.Quer...

It can be any number for condition like:
query.Where = "SUB_REGION = 'Pacific' or STATE_ABBR like 'A%' and POP2007 < 1000000"

You can try the query above on this service:
http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
Thanks jenefer
thats Work
One more thing to ask
I have a textbox for input value and i want to used it in the query below but no result occurs
query.Where = "FEILD1 like '%Textbox1.Text%' and FEILD2='TOWN BORDER STATION'"

i have done Serval Method like that
no result appers
query.Wo reshere = string.Format("Field1 = 'Textbox1.Text' and Field2 'Textbox2.Text'");

q.Where = "FEILD1 = '" & Textbox1.Text.Trim() & "' AND
FEILD2 = '" & Textbox2.Text.Trim() & "'"

it gives error on & operator

i m working on C#

How textbox values will be used in the query.where
0 Kudos
JenniferNery
Esri Regular Contributor
You can use string.Format() http://msdn.microsoft.com/en-us/library/system.string.format(v=VS.95).aspx


query.Where = string.Format("FEILD1 like '%{0}%' and FEILD2='TOWN BORDER STATION'", Textbox1.Text.Trim());
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
thanks jenniferdnery
its working

Another thing to ask
i have selected record from query that appers in DATAGRID
i want to used FeatureDataGRID instead of DATAGRID (is this  possible)?
if not
then how selected  DATGRID value  zoom to feature (on click event)
required code C#
thanks
regards
Waqar
0 Kudos
JenniferNery
Esri Regular Contributor
If you return query results to a GraphicsLayer, you can use this GraphicsLayer to set FeatureDataGrid.GraphicsLayer property. Very similar to this sample except you will be using the GraphicsLayer that contain your query results. http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataGrid

If your DataGrid contain GraphicCollection as its ItemsSource, you can use SelectionChanged event to get the selected row (which is a graphic) and call Map.ZoomTo(graphic.Geometry).
0 Kudos