fjchenq 发表于 2009-4-8 11:43:35

ADO编程疑问


Const $ADS_SCOPE_SUBTREE = 2
$objConnection = ObjCreate("ADODB.Connection")
$objCommand =   ObjCreate("ADODB.Command")
$objConnection.Provider = "ADsDSOObject"
$objConnection.Open("Active Directory Provider")
$objCommand.ActiveConnection = $objConnection
$objCommand.CommandText = _
    "SELECT distinguishedName FROM " _
      & "'LDAP://cn=Configuration,DC=fabrikam,DC=com' " _
            & "WHERE objectClass='Computer'"
$objCommand.Properties("Page Size") = 1000
$objCommand.Properties("Timeout") = 30
$objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
$objCommand.Properties("Cache Results") = False
$objRecordSet = $objCommand.Execute
$objRecordSet.MoveFirst
Do
    ConsoleWrite( "Computer Name: " & $objRecordSet.Fields("distinguishedName").Value & @CRLF)
    objRecordSet.MoveNext
Until objRecordSet.EOF
当程序执行到
$objCommand.ActiveConnection = $objConnection
就出错,我把其它全部注释掉

想问大家一句,遇到这种情况,应该如何解决?

[ 本帖最后由 fjchenq 于 2009-4-8 11:45 编辑 ]

hehui 发表于 2009-4-9 08:56:57

论坛上某位大哥写的有操作SQL数据库的例子,找找吧

akmm88 发表于 2009-4-9 20:09:49

$objConnection.Open("Active Directory Provider") 打开了没有呢?
$objConnection.Errors.Count 是不是>0?
AU3来操作取错误集应该是这么写吧,我没有用AU3弄过这个. 应该是差不多吧.

如果错误数量大于0.
$objConnection.Error.Description获得错误的简要说明
$objConnection.Error.Number 错误代码

fjchenq 发表于 2009-4-11 11:06:16

同样的脚本用VBScript执行起来没有问题.

我是从VBscript脚本转换过来了
页: [1]
查看完整版本: ADO编程疑问