Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
scripts
hosting
jscript
remote
scripting.wsh
scriptlets
vbscript
virus.discussion
  
 
date: Wed, 20 Aug 2008 00:42:28 -0700 (PDT),    group: microsoft.public.scripting.vbscript        back       


What does the .run method return   
Hi,

In my project i have the following existing code

Dim ret
set ws =  Wscript.CreateObject("Wscript.Shell")
ret = ws.run("\\C\knrtest\AQCM_Product_Delete_Config_Data.vbs
MIDTDB02402\SQL024301 Taurus_Dev_R4 NT NT AQCM_Config_New 3 0",7,true)
wscript.quit ret


Can you tell me what "ret" would contain.
I think it returns 0 or 1. if the stored procedure is executed or not.
Am i correct?

Thanks
Deepal
date: Wed, 20 Aug 2008 00:42:28 -0700 (PDT)   author:   unknown

Re: What does the .run method return   
It returns the exit code generated by the application you invoke.


 wrote in message 
news:70a2fb17-191b-4258-8f8a-da773a7018a8@y21g2000hsf.googlegroups.com...
> Hi,
>
> In my project i have the following existing code
>
> Dim ret
> set ws =  Wscript.CreateObject("Wscript.Shell")
> ret = ws.run("\\C\knrtest\AQCM_Product_Delete_Config_Data.vbs
> MIDTDB02402\SQL024301 Taurus_Dev_R4 NT NT AQCM_Config_New 3 0",7,true)
> wscript.quit ret
>
>
> Can you tell me what "ret" would contain.
> I think it returns 0 or 1. if the stored procedure is executed or not.
> Am i correct?
>
> Thanks
> Deepal
date: Wed, 20 Aug 2008 11:01:03 +0200   author:   Pegasus \(MVP\)

Re: What does the .run method return   
Thanks for the reply.
Just one more doubt. How do i fetch the paramteres that are returned
by the stored procedure?
date: Wed, 20 Aug 2008 02:18:20 -0700 (PDT)   author:   unknown

Re: What does the .run method return   
wrote in message 
news:1f7c5736-533e-4963-ac56-dc7b04223642@z66g2000hsc.googlegroups.com...
> Thanks for the reply.
> Just one more doubt. How do i fetch the paramteres that are returned
> by the stored procedure?

Parameters are used as *input* to a process; they are not
*returned* by a process. Are you perhaps referring to the
screen output of the process you invoke with the Run method?
If so then have a look here:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug06/hey0817.mspx
date: Wed, 20 Aug 2008 11:57:38 +0200   author:   Pegasus \(MVP\)

Re: What does the .run method return   
Out parameters are returned back and the In parameters are used as
input.
Fro example i can do
Set objParameter = objCommand.CreateParameter ("ConfirmID", 3, 2)
2- specifies that its an Out param

You can refer to
http://www.devguru.com/Technologies/ado/quickref/command_createparameter.html
for more details
But i just wanted to confirm if a record type can be declared or not
date: Wed, 20 Aug 2008 03:23:05 -0700 (PDT)   author:   unknown

Re: What does the .run method return   
On Aug 20, 6:23 am, deepal...@gmail.com wrote:
> Out parameters are returned back and the In parameters are used as
> input.
> Fro example i can do
> Set objParameter = objCommand.CreateParameter ("ConfirmID", 3, 2)
> 2- specifies that its an Out param
>
> You can refer tohttp://www.devguru.com/Technologies/ado/quickref/command_createparame...
> for more details
> But i just wanted to confirm if a record type can be declared or not

The short answer is NO.  I say that because your sample executes a VBS
script, not a database stored procedure.  VBS scripts can output text
to a console window or GUI message box.  But, they do not create
output parameters.

However, I am confused by your question.  In one place you reference
'stored procedure', yet your example is a VBS script.  Does your
script connect to a database in which there is a stored procedure?

Personally, I would need to see a snippet of code from that script and
have a better explanation of what exactly you're trying to accomplish
before I could comment further.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
date: Wed, 20 Aug 2008 05:16:55 -0700 (PDT)   author:   Tom Lavedas

Re: What does the .run method return   
> The short answer is NO.  I say that because your sample executes a VBS
> script, not a database stored procedure.  VBS scripts can output text
> to a console window or GUI message box.  But, they do not create
> output parameters.
>
> However, I am confused by your question.  In one place you reference
> 'stored procedure', yet your example is a VBS script.  Does your
> script connect to a database in which there is a stored procedure?
>
> Personally, I would need to see a snippet of code from that script and
> have a better explanation of what exactly you're trying to accomplish
> before I could comment further.
>
> Tom Lavedas
> ===========http://members.cox.net/tglbatch/wsh/

I have a batch job that calls a VBscript. This Vbscript connects to
the database and calls the stored procedure. The stored procedure
takes one input parameter and returns only one row with 2 column. both
the columns are integer.

Please find the code below
Batch job. Call to the VBscript

Dim ret
set ws =  Wscript.CreateObject("Wscript.Shell")
ret = ws.run("\\C\Delete_Data.vbs SQL024301 Taurus_ NT NT Config_New 3
0",7,true)
wscript.quit ret

VBscript..  pasting only the main function not all of them

'Main procedure
Sub delete_data

    WriteLog "Calling stored procedure
Product_DeleteReqItemResErr ..."

    On Error Resume Next
    Dim objCmd
    set objCmd = CreateObject("ADODB.Command")
'    set rs = CreateObject("ADODB.RecordSet")

   With objCmd
        .ActiveConnection = Scn
        .commandtimeout = 9000
        .CommandText = "test_Product_DeleteReqItemResErr"
        .CommandType = 4
        .Parameters.Append .CreateParameter("date_diff_days", 3, 1)

    End With
   rs = objCmd.Execute

'    If Not rs.EOF Then
'       outTotalConfigId = rs.Fields(0)
'       outTotalBundleId = rs.Fields(1)
'    End If

    Scn.CommandTimeout = 600
    On Error Resume Next

    If Err.Number <> 0 Then
        WriteLog Err.Description & " (" & Err.Number & ")"
        FatalError
    End If

    On Error Goto 0

    WriteLog "Product Config Deletion Success!"
    Writelog " Product Config Deletion Exit code is 0 "
    Closedown

    Wscript.quit 0
 End sub

Thanks
Deepal
date: Wed, 20 Aug 2008 05:42:54 -0700 (PDT)   author:   unknown

Re: What does the .run method return   
wrote in message 
news:7e3371cc-d4ef-4e2e-9642-282089cccdf0@f36g2000hsa.googlegroups.com...

> The short answer is NO. I say that because your sample executes a VBS
> script, not a database stored procedure. VBS scripts can output text
> to a console window or GUI message box. But, they do not create
> output parameters.
>
> However, I am confused by your question. In one place you reference
> 'stored procedure', yet your example is a VBS script. Does your
> script connect to a database in which there is a stored procedure?
>
> Personally, I would need to see a snippet of code from that script and
> have a better explanation of what exactly you're trying to accomplish
> before I could comment further.
>
> Tom Lavedas
> ===========http://members.cox.net/tglbatch/wsh/

I have a batch job that calls a VBscript. This Vbscript connects to
the database and calls the stored procedure. The stored procedure
takes one input parameter and returns only one row with 2 column. both
the columns are integer.

Please find the code below
Batch job. Call to the VBscript

Dim ret
set ws =  Wscript.CreateObject("Wscript.Shell")
ret = ws.run("\\C\Delete_Data.vbs SQL024301 Taurus_ NT NT Config_New 3
0",7,true)
wscript.quit ret

VBscript..  pasting only the main function not all of them

'Main procedure
Sub delete_data

    WriteLog "Calling stored procedure
Product_DeleteReqItemResErr ..."

    On Error Resume Next
    Dim objCmd
    set objCmd = CreateObject("ADODB.Command")
'    set rs = CreateObject("ADODB.RecordSet")

   With objCmd
        .ActiveConnection = Scn
        .commandtimeout = 9000
        .CommandText = "test_Product_DeleteReqItemResErr"
        .CommandType = 4
        .Parameters.Append .CreateParameter("date_diff_days", 3, 1)

    End With
   rs = objCmd.Execute

'    If Not rs.EOF Then
'       outTotalConfigId = rs.Fields(0)
'       outTotalBundleId = rs.Fields(1)
'    End If

    Scn.CommandTimeout = 600
    On Error Resume Next

    If Err.Number <> 0 Then
        WriteLog Err.Description & " (" & Err.Number & ")"
        FatalError
    End If

    On Error Goto 0

    WriteLog "Product Config Deletion Success!"
    Writelog " Product Config Deletion Exit code is 0 "
    Closedown

    Wscript.quit 0
 End sub

Thanks
Deepal
--------
Shouldn't it be:

Set rs = objCmd.Execute

I am able to set the CommandType property of ADO Command objects in 
VBScript.

The code to retrieve the two field values for the recordset is commented 
out, but I don't see how this can be returned using the Run method of the 
wshShell object. You could return one integer by specifing a value in the 
Quit method:

Wscript.Quit 5

I believe the Run method would then return 5.

In the VBS above you could write the values to a text file. Can you just 
skip the first VBS program (the one that runs this program) and do what you 
want in this second VBS program? Otherwise I think the solution is to write 
the values to a temporary file that the first VBScript program can read. Or, 
you might try using the Exec method of the wshShell object in the first 
program and reading StdOut. The second VBS would be revised to echo the 
values with Wscript.Echo commands.

-- 
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
date: Wed, 20 Aug 2008 13:52:30 -0500   author:   Richard Mueller [MVP]

Re: What does the .run method return   
Hi
Thanks for the help.
i used Set rs = objCmd.Execute and it works fine.
Also i had not declared rs
so i did a Dim rs and now its working as needed.

Thanks
date: Thu, 21 Aug 2008 02:31:57 -0700 (PDT)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us