Solved

Return Status from SQL Server - Executing Stored Procedure

Posted on 2001-06-27
3
666 Views
Last Modified: 2008-02-01
I'm using VB6 against SQL Server and I need some help.
From a drop-down menu in my VB app, I'd like to execute a stored procedure (an update which passes some parameters)
on SQL Server.

I'd like the sp to execute in the background and then pass a return code on completion or failure of the sp to the VB program;
Possibly display a message box to the user or some popup to let them know that the job completed.

Can anyone suggest the best way to do this?
I know sql server comes with a bunch of built-in sps; but the one closest to what I need is only suitable for OLE Automation.

Thanks in advance.

John
0
Comment
Question by:jtrapat1
3 Comments
 

Expert Comment

by:MarioK
ID: 6232153
Don't know if this will help, but here go's

After the SQL statement executed in your store procedure
you can query the value of the @@Error SQLserver variable
while still in the SP. If the @@Error = 0 then the SQL
statement executed without errors. You can then set a
return variable that VB will be able to to intrepid.

MK



0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6232454
Is this "job" lengthy (say minutes/hours)? in that case i would define a sql job (look under the SQL Server Agent part of the server in the Enterprise manager), you find a Jobs folder.

To start such a job, you can use the sp_startjob stored procedure. to find the result of this is a little bit more complicated...

If this goes into the direction you want, we can continue to solve the small technical details...

Cheers
0
 
LVL 7

Accepted Solution

by:
John844 earned 200 total points
ID: 6232648
one way to chest is to send some identifyer to the stored procedure to let you know what user is running stored procedure currently.  inside the stored procedure execute your items, trap any errors using @@Error.  If an error occurs, write a item to a log table with the userid time and error message.  if no errors have occured at the bottom of the sp, then write a row to the log table indicating success.  Execute the sp asyncronously without expecting a recordset back(adexecutenorecords).  check the contents of the table periodically to inform user of success or failure.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now