帮下我!看能否这样来查询?

Clusting 2002-06-23 11:13:54
我想用ADO来查询Exchange中的某个目录中的记录,但想用自定义的属性作为
条件来进行查询,就如这样:
SELECT "DAV:displayname","DAV:href","custom:MyProperty"
FROM Scope('shallow traversal of "file://./somefolder/" ')
WHERE "custom:MyProperty" = "MyValue"
我已试了好多次了,它都会有“the submited SQL is incompleted”的错误提示,
我不知道这种想法究竟能不能实现,应为像"DAV:isfolder","DAV:ishidder"这样
的属性是能作为查询条件的,但是像"DAV:displayname","DAV:contentclass"这些
却又不行,大家能否给个方法我呢?
...全文
25 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lnliliang 2002-06-28
  • 打赏
  • 举报
回复
我做过的例子中,如果把自定义属性放在where子句中,就会报和你同样的错误,所以后来我把自定义属性从where子句中删掉了。使用内容类来过滤,然后再用代码来用自定义属性过滤。
这个问题很奇怪,是不是与环境有关系!
lnliliang 2002-06-28
  • 打赏
  • 举报
回复
我做过的例子中,如果把自定义属性放在where子句中,就会报和你同样的错误,所以后来我把自定义属性从where子句中删掉了。使用内容类来过滤,然后再用代码来用自定义属性过滤。
这个问题很奇怪,是不是与环境有关系!
storm97 2002-06-28
  • 打赏
  • 举报
回复
your sql statment is wrong!
pls check again!
scgqq 2002-06-26
  • 打赏
  • 举报
回复
file://../backofficestorage/这儿是两点吧!
下面是我的源程序,运行无误的。 where子句里全是自定义属性。
<%
dim strDataUrl
strDataUrl=Request.QueryString("Dataurl")
' any quotes within the string.
Function AddQuotes(strValue)
' Given a string, wrap it in quotes, doubling
Const QUOTE = """"
AddQuotes = _
QUOTE _
& Replace(strValue, QUOTE, QUOTE & QUOTE) _
& QUOTE
End Function


' using ADO.

Dim cnn 'As ADODB.Connection
Dim rst 'As ADODB.Recordset
Dim urlQueryFld 'As String
Dim strSQL 'As String


' Get the URL to the animals folder
urlQueryFld = request.querystring("dataurl")

' Connect to the URL
Set cnn = CreateObject("ADODB.Connection")
With cnn
.Provider = "exoledb.datasource"
.Open urlQueryFld
End With

' Build the SQL query

strSQL = "Select " & _
AddQuotes("DAV:displayname") & ", " & _
AddQuotes("DAV:contentclass") & ", " & _
AddQuotes("Personal:formname") & ", " & _
AddQuotes("Personal:author") & ", " & _
AddQuotes("Personal:manager") & ", " & _
AddQuotes("Personal:requestdate") & ", " & _
AddQuotes("Personal:issubmit") & ", " & _
AddQuotes("Personal:istotal") & ", " & _
AddQuotes("Personal:isread") & ", " & _

AddQuotes("DAV:href")
strSQL = strSQL & _
" FROM SCOPE('SHALLOW traversal of " & _
AddQuotes(urlQueryFld) & "')"
strSQL = strSQL & _
" WHERE (" & AddQuotes("DAV:contentclass") & _
" = 'requestform:content-classes:personal' "

strSQL=strSQL & _
" And "& AddQuotes("Personal:issubmit") & _
" ='true' "
strSQL=strSQL & _
" And "& AddQuotes("Personal:istotal") & _
" ='false' "
strSQL=strSQL & _
" And "& AddQuotes("Personal:isread") & _
" ='false')"

strSQL = strSQL & _
" ORDER BY " & AddQuotes("Personal:requestdate")


' Get the results of the query
Set rst = CreateObject("ADODB.Recordset")
With rst
.Open strSQL, cnn
End With


response.Write "<table>"

Do Until rst.EOF
response.Write "<tr><td width=800>"
%>
<a href="../request/<%=rst.Fields("DAV:displayname")%>?cmd=edit">
<h4><%=rst.Fields("Personal:author")%>    <%=rst.Fields("Personal:requestdate")%></h4></a>

<%
response.Write "</td></tr>"
rst.MoveNext
Loop

response.Write "</table>"

' Close the ADO object
rst.Close
cnn.Close

' Release memory used by object variables
Set rst = Nothing
Set cnn = Nothing
%>
Clusting 2002-06-25
  • 打赏
  • 举报
回复
我还是没搞定,大家再帮下我吧。 :(
scgqq 2002-06-24
  • 打赏
  • 举报
回复
你的查询路径是错的,自定义属性能做查询条件
storm97 2002-06-24
  • 打赏
  • 举报
回复
your sql traversal path is wrong!
Clusting 2002-06-24
  • 打赏
  • 举报
回复
我上面的查询路径只是举个例子而已,我相信我在程序里的路径是正确的,因为
当我去掉where子句时就可以正确查询了,可以得到该目录下的所有项目,而一
加上where时就出现“the submited SQL is incompleted”

storm97(风暴不再),scgqq(轻骑兵) 两位大哥给我再指点下吧。:)

我当时用的查询路径是 类似这样的"file://./backofficestorage/mydns.com/MyStorage/MyPublicFolder/SomeFolder/"

路径是我的自建的一个公共目录,且我自定了一个内容类,使保存到这个目录的项目都的"DAV:contentclass"为该内容类.我该怎么么来使用自定义属性来进行查询。多谢了。
AChu 2002-06-23
  • 打赏
  • 举报
回复
看看exchange的sdk,上面已经提到过像DAV:href等是不能放在where字句中作为查询条件的。因为这些值是自动计算出来的。:)
至于想用自定义的属性作为条件来查询,你需要将你的自定义属性定义为content-class。
Clusting 2002-06-23
  • 打赏
  • 举报
回复
我是这样的,我新建了一个内容类,我使某个目录的所有项目都为该内容类的实例,因此很想通过这种方法进行查询。
我看了一下Exchange的sdk,在一些例子的WHERE子句中确有这个用法,如在Cust
函数的用法中就可找到,但我花了好久时间也不知道怎么来使用它们。
大家帮下忙吧!

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧