Solved

Return Status from SQL Server - Executing Stored Procedure

Posted on 2001-06-27
3
673 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 143

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

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 69
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 66
Publisher:   Unknown     VB.exe Application 1 31
Macro problems with Excel file 6 22
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

685 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