I need to Create a CAML Query Dynamically with VB to a Sharepoint
WebService GetListItems Method.

The User Could Select 1 to X Number of IDs from a list Box. For a
Database Id I would create the Query String Dynamically, but I can't
figure out how to do this with CAML queries


To Create Database SQL Query with VB would look something like this, (i
don't know if this code works, its just to show an example)
*************************
Dim SelectStr As String
Dim Element As String

SelectStr = "Select * from table where "

For Each Element in StringArray
SelectStr += "ID=" & Element & " or "
Next
Dim Idx As Integer = SelectStr = LastIndexOf(" or ")
SelectStr = SelectStr.Substring(0,Idx)
**************************
The Result is a sql String something like : "Select * from table where
ID=1 or ID=5 Or ID=7 Or ID=89"


The Problem I'm Having is Creating a CAML Query like the SQL Query
above. I can't figure out the pattern of where the <Or> Tag needs to go
based on the Number of Filter Fields. Example for two Fields the query
would look like:
<Where>
<Or>
<Eq>
<FieldRef Name='ID'/>
<Value Type='Number'>1</Value>
</Eq>
<Eq>
<FieldRef Name='ID'/>
<Value Type='Number'>5</Value>
</Eq>
</Or>
</Where>

But Placement of the <Or> Tag Changes as you add Fields:
<Where>
<Or> 'Added to Handle Third Field
<Or>
<Eq>
<FieldRef Name='ID'/>
<Value Type='Number'>1</Value>
</Eq>
<Eq>
<FieldRef Name='ID'/>
<Value Type='Number'>5</Value>
</Eq>
</Or>
<Eq>
<FieldRef Name='ID'/>
<Value Type='Number'>7</Value>
</Eq>
</Or>
</Where>


Thanks,
Jon

*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!