How to simulate SQL IN syntax in a CAML query
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
How to simulate SQL IN syntax in a CAML query

 
Post new topic   Reply to topic    Windows Server Forum Index -> Windows Services
Author Message
Bense
Guest





Posted: Thu Jan 20, 2005 10:59 pm    Post subject: How to simulate SQL IN syntax in a CAML query Reply with quote

I am trying to use the WSS SPQuery class to select a list of items based on
the Filenames of the documents. However, this query syntax does not work for
the query text.

The query should simulate a SQL IN statement using OR query syntax.

string sQuery=
"<Where>
<Or>
<Eq>
<FieldRef Name='FileLeafRef'/>
<Value Type='File'>DocumentStoreAuditFinal.doc</Value>
</Eq>
<Eq><FieldRef Name='FileLeafRef'/>
<Value Type='File'>DocumentStoreAudit .doc</Value>
</Eq>
</Or>
</Where>";

SPQuery=new SPQuery();
query.Query =sQuery;

SPListItemCollection items = contextDocLibrary.GetItems(query);

I keep getting "Cannot complete this action. Try again." Any pointers to fix
this would be helpful.

Thanks
Back to top
Mike Walsh
Guest





Posted: Thu Jan 20, 2005 11:35 pm    Post subject: Re: How to simulate SQL IN syntax in a CAML query Reply with quote

Please post this kind of CAML / use of WSS SPQuery class query to the
subnewsgroup for WSS programming at

microsoft.public.sharepoint.windowsservices.development

which has been set up for all kinds of programming questions (Web Services
usage; web part creation and amendment and CAML)

Please also in future only send programming questions there to keep a clear
split betwen the two newsgroups.

Thanks.

Mike Walsh, Helsinki, Finland
WSS FAQ at http://wss.collutions.com
Please reply to the newsgroup
"Bense" <Bense@discussions.microsoft.com> wrote in message
news:3FFEABE5-B6C7-4A93-B2BF-2E1B0A03402F@microsoft.com...
Quote:
I am trying to use the WSS SPQuery class to select a list of items based on
the Filenames of the documents. However, this query syntax does not work
for
the query text.

The query should simulate a SQL IN statement using OR query syntax.

string sQuery=
"<Where
Or
Eq
FieldRef Name='FileLeafRef'/
Value Type='File'>DocumentStoreAuditFinal.doc</Value
/Eq
Eq><FieldRef Name='FileLeafRef'/
Value Type='File'>DocumentStoreAudit .doc</Value
/Eq
/Or
/Where>";

SPQuery=new SPQuery();
query.Query =sQuery;

SPListItemCollection items = contextDocLibrary.GetItems(query);

I keep getting "Cannot complete this action. Try again." Any pointers to
fix
this would be helpful.

Thanks

Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Windows Services All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB