I am trying to loop on a recordset returned from db2 using a .wsf file and vbscript .
the vbscript libfile(lib.vbs) is as follows
'***************
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
'************************
I am using a trial.wsf file , to getback a recordset on which i am trying to loop
<?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>
My intial thinking was that the cursor type might be wrong ,
but i am not even able to set the cursosr type to dynamic , got a vbscript error not supported .
maybe its an issue with the provider , but am not able to confirm that .
I want to do something like this , but am not able to loop on the recordset ..
Do While Not objRS.EOF
Select Case UCase(trim(objRS("NAME").Value))
Case "SOAPSERVER" SOAPSERVER=objRS("VALUE").Value
Case "SOAPMESSAGE" SOAPMESSAGE=objRS("VALUE").Value
Case "SOAPACTION" SOAPACTION=objRS("VALUE").Value
Case Else ErrorOut "Error: InCorrect Value"
End Select
objRS.MoveNext
Loop
Am sure there is something basic/silly mistake over here , not well versed with wsf and scripting ..