DB2Recordset.MoveNext不支持WSF和ADO,vbscript中出现错误

DB2Recordset.MoveNext不支持WSF和ADO,vbscript中出现错误,vbscript,db2,ado,wsh,Vbscript,Db2,Ado,Wsh,我试图使用.wsf文件和vbscript循环从db2返回的记录集 vbscript libfile(lib.vbs)如下所示 '*************** Const ADOCon="Provider=IBMDADB2.1;Password=*****;User ID=*****;Data Source=yourdatasourc;" '************************ 'ADO environment is Initialised here '*********

我试图使用.wsf文件和vbscript循环从db2返回的记录集

vbscript libfile(lib.vbs)如下所示

'***************  
Const ADOCon="Provider=IBMDADB2.1;Password=*****;User ID=*****;Data Source=yourdatasourc;"
'************************  
'ADO environment is Initialised here  
'*************************  
Function ADOINI(strDB2Cn)  
  With objConnection  
        .Open strSQLCn  
        .CursorLocation=adUseClient  
  End With  
  If objConnection.Errors.Count > 0 Then  
        ErrorOut "Conncetion has Failed."  
  End If  
  With objCommand  
        .ActiveConnection = objConnection  
        .CommandType = adCmdText           
  End With    
End Function  
'********************    
'Execute ADO Comand  
'strSQL - SQL Statment to execute     
'Return ADO RecordSet.  
'*******************************    
Function Exec(strSQL)  
    objCommand.CommandText = strSQL  
    Exec=objCommand.Execute  
End Function  
'******************************************    
    Function ErrorOut(errMsg)  
        Wscript.StdErr.Write Now()&" "&errMsg&vbCrLf   
    End Function  
'****************    
    Function StdOut(msg)   
        WScript.StdOut.Write Now()&" "&msg&vbCrLf   
    End Function  
'************************  
我正在使用一个trial.wsf文件来取回我试图循环的记录集

<?xml version="1.0" encoding="utf-8" ?>  
<package xmlns="http://schemas.microsoft.com/WindowsScriptHost">  
<job id="main">  
<object id="objConnection"  progid="ADODB.Connection" />  
<object id="objCommand"     progid="ADODB.Command" />  
<object id="objError"       progid="ADODB.Error" />  
<reference object="ADODB.Connection" />  
<reference object="ADODB.Command" />  
<reference object="ADODB.Error" />  

<script language="VBScript" src="lib.vbs">  

    ADOINI(ADOCon)      
    Set objRS = Exec("SELECT REF_CRSETTINGS.NAME, REF_CRSETTINGS.VALUE FROM   WMRCR.REF_CRSETTINGS REF_CRSETTINGS WHERE TRIM(UPPER(REF_CRSETTINGS.CATEGORY)) IN   ('SAMPLE_SETTINGS') ORDER BY REF_CRSETTINGS.CRSETTINGSCODE")  

' the above recordset is a name value pair based on the category   

 StdOut objRS("NAME").Value 'this worked fine  

objRS.MoveNext ' this doesnt work neither does check for EOF or BOF   

</script>  
</job>  
</package>  

我确信这里有一些基本的/愚蠢的错误,不熟悉wsf和脚本

根据评论中提到的KB文章,您可能只想使用将记录集转储到数组中。获取行并处理数组

函数是一段命名代码,它通过(在VBScript中)分配给函数名返回某些内容。库中的大多数“函数”没有,因此也不是

函数Exec尝试返回一个记录集,即一个对象。VBScript中的对象分配需要
Set
。因此:

Function Exec(strSQL)  
    objCommand.CommandText = strSQL  
    Set Exec=objCommand.Execute  
End Function  
你看到了吗?
Function Exec(strSQL)  
    objCommand.CommandText = strSQL  
    Set Exec=objCommand.Execute  
End Function