Ask a Question related to ASP.NET Web Services, Design and Development.
-
Jon F. #1
CAML Query: Multiple Query Fields Issue
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!
Jon F. Guest
-
Fields missing in query
I am having an odd problem. I have a table in MSSQL named Residential. In this table I have 32 fields (all of which I use) for some reason all of... -
Query to find MAX(SUM()) of X consecutive fields
Hello All, I have a database containing measurement data in which data is added every 5 minutes. I would like to get the hour in which the highest... -
Crosstab Query with Date Fields
Pulling my hair out! Ok here's what I got: I need to output 2 queries with 2 different datefields with different Years (2 max) in tabular format... -
Syntax for ambigous fields in a query with joins?
Hello, I run a select query in PHP using 1 table joined to 3 other tables. All well and good, but there are fields in these tables that have... -
Crosstab query with multiple value fields
Hi again, Is it possible for a crosstab query to have multiple value fields ? The way I'm working now is to create separate crosstabs (about...



Reply With Quote

