hangover


How do I make the "Running query..." progress bar display when executing an SQL query within my VFP9 application

I have tried both SET TALK ON and SET NOTIFY ON but it is still not displaying. Which other commands can affect whether it is displayed or not

Thanks.





Re: Display "Running query..." progress bar

Naomi Nosonovsky


This is a class by Mike Yearwood:

Code Snippet

**************************************************
*-- Class: cussqlthermo
*-- ParentClass:
*-- BaseClass: line

*---Created by: Mike Yearwood
*-- Time Stamp: 10/18/05 09:07:11 PM
*
DEFINE CLASS CusSqlThermo AS LINE

*-- Holds SET TALK setting at initialization.
PROTECTED cOldSetTalk
cOldSetTalk = ""
*-- Holds SET NOTIFY setting at initialization.
PROTECTED cOldSetNotify
cOldSetNotify = ""
*-- Holds the output window at initialization.
PROTECTED cOldOutputWindow
cOldOutputWindow = ""
*-- Holds the name of the temporary output window.
PROTECTED cNewOutputWindow
cNewOutputWindow = ""
*----Holds Escape settings
PROTECTED cOnEscape
cOnEscape= ""
PROTECTED cSetEscape
cSetEscape = ""
NAME = "CusSqlThermo"

PROCEDURE DESTROY
SET TALK OFF
LOCAL ;
lcNewOutputWindow, ;
lcOldOutputWindow, ;
lcOldSetNotify, ;
lcOldSetTalk, lcOnEscape, lcSetEscape

WITH THIS
lcNewOutputWindow = .cNewOutputWindow
lcOldOutputWindow = .cOldOutputWindow
lcOldSetNotify = .cOldSetNotify
lcOldSetTalk = .cOldSetTalk
lcOnEscape = .cOnEscape
lcSetEscape = .cSetEscape
ENDWITH

IF VERSION(5)>=700
SET NOTIFY &lcOldSetNotify
ENDIF

SET TALK &lcOldOutputWindow

RELEASE WINDOWS &lcNewOutputWindow

SET TALK &lcOldSetTalk
* Now restore our settings
ON ESCAPE &lcOnEscape

IF m.lcSetEscape = "OFF"
SET ESCAPE OFF
ELSE
SET ESCAPE ON
ENDIF

ENDPROC

PROCEDURE INIT
*Class that activates SQL thermometer bar during init
*and restores altered settings during destroy.

WITH THIS

.cOldSetTalk = SET("TALK")
SET TALK OFF

.cOldOutputWindow = SET("TALK",1)
.cNewOutputWindow = "SQLThermo" + SYS(2015)
.cOnEscape = ON('ESCAPE')
.cSetEscape = SET('ESCAPE')

SET ESCAPE ON
ON ESCAPE plStop = YesNo("Are you sure you want to stop ")

LOCAL lcNewOutputWindow
lcNewOutputWindow = .cNewOutputWindow
DEFINE WINDOW &lcNewOutputWindow. FROM -1000,-1000 TO -500,-500
ACTIVATE WINDOW &lcNewOutputWindow. IN SCREEN

SET TALK WINDOW &lcNewOutputWindow
IF VERSION(5)>=700
.cOldSetNotify = SET("NOTIFY")
SET NOTIFY ON
ENDIF
ENDWITH

SET TALK ON

RETURN .T.
ENDPROC

ENDDEFINE
*


*-- EndDefine: cussqlthermo

Just create an instance of this class before running queries. I enhanced it with an ability to interrupt long queries.






Re: Display "Running query..." progress bar

Naomi Nosonovsky

BTW, if this progress bar will be shown or not depends on various factors internally. In other words, you can not 100% guarantee this progress bar always shown, VFP has mind of its own when to show the progress bar.




Re: Display "Running query..." progress bar

hangover

Many thanks Naomi. I've tried using the above code but the progress bar still does not display.

I guess it must be due, as you say, to the idiosyncracies of VFP.






Re: Display "Running query..." progress bar

Naomi Nosonovsky

Yes, may be VFP thinks it is not going to take long time to run it. Anyway, this class can come handy for other selects.



Re: Display "Running query..." progress bar

dni

You may use control from:

http://support.microsoft.com/kb/254478

It is working fine.






Re: Display "Running query..." progress bar

Naomi Nosonovsky

How this ActiveX control is related with running SQL queries Also I would rather use Carlos Alloatti controls for progress bar, since they are written in VFP code (Windows API).



Re: Display "Running query..." progress bar

dni

You may add a new method. It is a stable thing, no SP's and free.




Re: Display "Running query..." progress bar

Naomi Nosonovsky

I can understand how do you add progress bar in SCAN loops or other loops, but I still don't see how would you update it in SQL query. Of course, you can use UDF in Select SQL to do that, but I doubt anyone would like this.

If you're using SQL pass-through, you can have a progress bar.





Re: Display "Running query..." progress bar

dni

See, you just begun to find solutions. I remember you that "the subject was the roses" in this thread, not my answer ...




Re: Display "Running query..." progress bar

Naomi Nosonovsky

Sorry, I don't understand what do you mean by your last reply.