Solved

return value of xp_cmdshell

Posted on 2000-08-04
4
1,016 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 143

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

734 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