PDA

View Full Version : SQL Stored Procedure Progress


Empty
05-15-2005, 04:15 PM
Is it posible to get the progress of a stored procedure? If not, is it possible to run a thread to make a progressbar type control scroll while the procedure is running? Everytime i try to make a thread to run either the stored procedure or the progressbar control the program freezes on the stored procedure.

Regards
AJ

brendalisalowe
06-02-2005, 04:45 PM
Sometimes I just do this:


Me.Cursor = Cursors.WaitCursor
............................
Me.Cursor = Cursors.Default


Maybe something is wrong with your stored proc if it is freezing...

Empty
06-05-2005, 05:17 PM
Hi Brenda,

Thanks for your reply. Here is my Stored Proc:



CREATE PROCEDURE [TotalCostUpdate] AS
DECLARE @ID INT, @Rate Real, @HourCost Real, @Employee nvarchar(18), @Hours Real, @Date Char(8)

DECLARE SheetList CURSOR FOR
SELECT TSNO, EMPLOYEE, HOURS, CONVERT(Char(8), [Date], 112) as [Date]
FROM TSHEET

OPEN SheetList

FETCH NEXT FROM SheetList
INTO @ID, @Employee, @Hours, @Date

WHILE @@FETCH_STATUS = 0
BEGIN
SET @HourCost = 0
SET @Rate = 0

SELECT @Rate =
CASE MONTH(@Date)
WHEN 1 THEN RATE1
WHEN 2 THEN RATE2
WHEN 3 THEN RATE3
WHEN 4 THEN RATE4
WHEN 5 THEN RATE5
WHEN 6 THEN RATE6
WHEN 7 THEN RATE7
WHEN 8 THEN RATE8
WHEN 9 THEN RATE9
WHEN 10 THEN RATE10
WHEN 11 THEN RATE11
WHEN 12 THEN RATE12
END
FROM CORATE
WHERE YEAR = Left(@Date, 4) AND EMPLOYEE = @Employee

SET @HourCost = ISNULL(@Hours, 0) * ISNULL(@Rate, 0)

UPDATE TSHEET SET COST = @HourCost WHERE TSNO = @ID

FETCH NEXT FROM SheetList
INTO @ID, @Employee, @Hours, @Date
END

CLOSE SheetList
DEALLOCATE SheetList
GO



Just to clarify, the program just freezes until the stored proc has finished. Is there a way to make the program usable while the staored proc is running?

Thanks AJ

jayceepoo
06-07-2005, 04:32 PM
You can have the commad that kicks off the stored procedure run on a different thread. That way it is running and it doesn't make your program appear to have crashed.

MKoslof
06-09-2005, 11:57 AM
Regarding threading, queries, databases and populating controls look at this past thread:

http://www.xtremevbtalk.com/showthread.php?t=186187

RonFriesen
07-01-2005, 01:07 PM
Check out this link. Monitoring SQL Server Progress in Visual Basic (http://www.punctualgraphics.com/Articles/A20030711/A20030711_p01.htm)

MKoslof
07-01-2005, 03:48 PM
Excellent article Ron, thanks for sharing :)

Empty
07-05-2005, 04:15 PM
Sorry about the slow reply guys, but i have been a little proccupied by personal things of late...

I was able to get the threading working fine, i will now try out Ron's article!

Thanks alot for the help!
AJ

Empty
07-05-2005, 08:36 PM
Thanks guys, just tryed that article and it worked perfectly :D