Query Where Clause

5377
5
02-10-2011 07:24 AM
JayKappy
Occasional Contributor
looking to to take the values from a textblock and run that through a query....
But I am looking to make sure its a wildcard search...

Questions:
query.OutFields.Add("*") - Does this give the query parameters to search these fields?

Something like this were its:
returning all fields so I can populate a listbox
Grabing the value from the FindAddress Textblock
Look in [Address] Field Where LIKE value from FindAddress Textblock

Think I just need a syntax check on the WHERE clause??

Thouhts

        Dim query As New ESRI.ArcGIS.Client.Tasks.Query()
        query.OutFields.Add("*")
        query.Text = FindAddress.Text
        query.Where = [Address] Like FindAddress.Text
        query.ReturnGeometry = True
        query.OutSpatialReference = MyMap.SpatialReference
        queryTask.ExecuteAsync(query)
0 Kudos
5 Replies
JayKappy
Occasional Contributor
Just llooking to make sure its a wildcard search....it might be right off the bat I dont know....

If it is then I would also like to know how to specify a query to query the whole value, whole value starting from beginning of the textblock etc.
0 Kudos
JayKappy
Occasional Contributor
Actually having a few issues with the Address Field....

Example Value: 7707 SMITH AVE N

I get "7707 SMITH AVE N" to return in a window as seen in the code below...but query does not find anything...I know the value exists in the data with exact spelling....
Can the fact that there is spaces be messing things up...

If I search for "1211922220012" which is a PID value in the PID field it finds it fine.

BUT AGAIN ultimate goal is to be a wildcard search

        Dim query As New ESRI.ArcGIS.Client.Tasks.Query()
        query.OutFields.Add("*")
        query.Text = FindAddress.Text
        query.ReturnGeometry = True
        query.OutSpatialReference = MyMap.SpatialReference
        queryTask.ExecuteAsync(query)

        MessageBox.Show(FindAddress.Text)
0 Kudos
JayKappy
Occasional Contributor
Seems like I have answered a couple of my questions....
Seems the below will search and return partial values on the Field PID.
So it appears that it is automatically doing a wildcard search

        Dim query As New ESRI.ArcGIS.Client.Tasks.Query()
        query.OutFields.Add("PID")
        query.Text = FindAddress.Text
        query.ReturnGeometry = True
        query.OutSpatialReference = MyMap.SpatialReference
        queryTask.ExecuteAsync(query)


Last thing...why cant I find a string field with spaces?  I verified that the value exists in the data and that the spelling was correct.
Still cant find it....Something to do with the Spaces???

7707 SMITH AVE N

Any thoughts
0 Kudos
AliMirzabeigi
New Contributor
Jay,

I suggest you to use the LIKE operator while querying string values. The following code snippet looks for all rows that contain the trimmed string in your FindAddress TextBox control:

query.Where = string.Format("Address LIKE '%{0}%'", FindAddress.Text.Trim());
0 Kudos
JayKappy
Occasional Contributor
Absolutly Fantastic....Thank you very much Ali...I was trying that above in my first post but did not have the syntaqx nearly correct...


Very appreciated.
0 Kudos