views:

81

answers:

2

Hi,

I'm using caml query to retrieve data from sharepoint list. The issue is that the query returns one record when it shouldn't, and this takes place only when I'm using this query in my own code. When I'm using the same query, on the same list by U2U Caml Query Builder it works wright.

My query is like this:

<Query><Where><Eq><FieldRef Name="Account_x0020_Verification_x0020" /><Value Type="Text">211edd1d11844d6c9f21d7930683caba</Value></Eq></Where></Query>

and the vb.net code I'm using to fired it up is like this:

 Dim oUserAccStatusList As SPList = oElevatedSPWeb.Lists(sListName)
                Dim oSPQuery As New SPQuery
                oSPQuery.Query = "<Query><Where><Eq><FieldRef Name='Account_x0020_Verification_x0020' /><Value Type='Text'>" + _sUserID + "</Value></Eq></Where></Query>"
                Dim oItems As SPListItemCollection = oUserAccStatusList.GetItems(oSPQuery)
                If oItems.Count <= 0 Then

Items.Count is 1 and inside it there is a record with userid different than I was asking for. Do anybody knows what's going on, and why does it happened?

+1  A: 

remove the query node out of the oSPQuery.Query property.

oSPQuery.Query = "<Where><Eq><FieldRef Name='Account_x0020_Verification_x0020' /><Value Type='Text'>" + _sUserID + "</Value></Eq></Where>"
David
This is one really nasty issue.
Janis Veinbergs
A: 

It works, but why do they in many tutorials always put query tag on the beginning as I was done previously on the beginning?

truthseeker