Solved

return value of xp_cmdshell

Posted on 2000-08-04
4
995 Views
Last Modified: 2012-05-04
I am creating a VB program.  I am calling the program from an SQL stored procedure using xp_cmdshell.  Xp_cmdshell returns a value of 1 for success and 0 for failure.  In the VB program how do I effect the return value of xp_cmdshell from a VB program?  
0
Comment
Question by:mnachtrab
4 Comments
 
LVL 2

Expert Comment

by:Slava_K
ID: 3785442
Why whould you do that? Can you explain.
0
 
LVL 3

Accepted Solution

by:
meos earned 25 total points
ID: 3785572
In this example, the xp_cmdshell extended stored procedure also suggests return status. The return code value is stored in the variable @result.

DECLARE @result int

EXEC @result = xp_cmdshell 'dir *.exe'

IF (@result = 0)

    PRINT 'Success'

ELSE

    PRINT 'Failure'
0
 
LVL 20

Expert Comment

by:hes
ID: 3785955
Declare this in your form (or if in a bas make it Public)

Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)

When you want to exit
If you want to send a 0
ExitProcess 0&

For a one (1)

ExitProcess 1&

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 3798154
I think you are looking for something like this:

dim adoCommand as ADODB.Command
set adoCommand = new adodb.command
with adoCommand
  .CommandText = "xp_cmdshell"
  .CommantType = adCmdStoredProc
  .Parameters.Append (.CreateParameter("command", adVarchar, adParamInput, 200, "DIR *.*" ))
  .Execute adExecuteNoRecords

  debug.print .Parameters(0).Value
End With
set adoCommand = nothing

Hope this helps
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question