CAML 问题的奇怪行为 - 为什么?
我正在使用 caml 查询从共享点列表中检索数据。 问题在于,查询在不应该返回的情况下返回了一条记录,并且只有当我在自己的代码中使用此查询时才会发生这种情况。 当我使用相同的查询时,在 U2U Caml 查询生成器的同一个列表上,它可以正常工作。
我的查询是这样的:
<Query><Where><Eq><FieldRef Name="Account_x0020_Verification_x0020" /><Value Type="Text">211edd1d11844d6c9f21d7930683caba</Value></Eq></Where></Query>
我用来启动它的 vb.net 代码是这样的:
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 是 1,其中有一条记录的 userid 与我要求的不同。有谁知道发生了什么事,为什么会发生?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 oSPQuery.Query 属性中删除查询节点。
remove the query node out of the oSPQuery.Query property.