Option Explicit ' ' This little VB Script program is used to retrieve ' a resultset from a stored procedure using ADO and the ' iSeries ODBC driver. ' ' If it completes successfully, a message box will ' display showing the number of rows fetched. ' ' Otherwise, this script doesn't invoke error ' trapping so an error box will display a problem. ' ' ' NOTE: Rename this to just have a .VBS extension ' in order to modify and use it. ' ' ' ' Connection String to iSeries ' (***REPLACE YOUR SPECIFIC DATA HERE***) ' ========================================== ' ' DSN=ODBC Data Source Name ' DBQ=Library List ' CMT=Commitment Control 0=None ' UID=User Name ' PWD=Password ' NAM=Naming Convention (0=SQL 1=System) ' Const con400Connect = "DSN=AS400;DBQ=,QTEMP,QGPL;CMT=0;NAM=1;UID=USERNAME;PWD=PASSWORD" ' ' ADO Stuff ' Const adCmdText = 1 Dim conn400, cmd400, rs400 Dim lngCount Set conn400 = CreateObject("ADODB.Connection") Set cmd400 = CreateObject("ADODB.Command") ' ' Open Connection to the 400 ' conn400.Open con400Connect ' ' Attempt to run stored procedure ' with cmd400 .ActiveConnection=conn400 .CommandType=adCmdText .CommandText="{ Call TESTSQL }" Set rs400=.Execute End With ' ' Count the number of rows returned ' With rs400 lngCount=0 Do until .Eof lngCount=lngCount+1 .MoveNext Loop .Close End With MsgBox lngCount & " Records were returned from stored procedure" ' ' Cleanup Connection ' Set rs400 = Nothing Set cmd400 = Nothing Set conn400 = Nothing ' ' Normal Completion ' WScript.Quit (0)