Query task where clause with 'AND'
I've been trying to add to this where clause but have had no luck. It works fine as is but I need to add: AND TYPE = Hydrant. Any suggestions?
"System ='"+ String.Format("{0}", objWaterSys) + "'"
0
-
Hi Rebecca,
Please see the .Net Fiddle for an example of how to format the query. https://dotnetfiddle.net/E9RYoi
-Kevin0 -
Thanks Kevin. That makes sense logically but I'm still not forming the expression correctly. Here's what I tried (no judging!):
"System ='"+ String.Format("System = {0} AND TYPE = 'Hydrant'", objWaterSys, "Hydrant") + "'"0 -
Hi Rebecca,
You really don't need any code outside of the String.Format call. All string manipulation can and should be done within that method.
Also, to point out that the 'Hyrant' string is not being replaced.
Try clause = String.Format("System = '{0}' AND TYPE = 'Hydrant'", objWaterSys) in an assign activity.
-Kevin0 -
I changed it to this but still getting an error:
0 -
String.Format("System = '{0}' AND TYPE = 'Hydrant'", objWaterSys) 0 -
Nevermind! I was trying to use the text in the expression editor but when I assigned it to a string variable and used the string it worked. I still don't undertand why it wouldn't work directly in the expression editor for the where clause but it's working now! 0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
6 kommentarer