Canceling query execution
Canceling query execution
What is the recommended way to cancel long running queries?
Re: Canceling query execution
I don't know a way to cancel the execution of a query (SqlPrepareAndExecute() or SqlExecute()).
But you can cancel the SqlFetchNext() loop.
Up to TD 4.2 we enabled message yielding for the whole form window while looping through the records.
Starting with TD 7.4.1 we had to enable message yielding for the internal parent of the form windows (which is something between the title bar of the form window and its contents).
We have a push button pbCancel. If you click this button, the window variable w_bCancel is set to TRUE.
We do only continue the loop, if w_bCancel is FALSE.
Don't forgett to disable message yielding after this.
TD 4.2 code:
TD 7.4.1 code:
GetParent() is an external function from USER32.DLL which is declared as follows
Regards,
Rainer
But you can cancel the SqlFetchNext() loop.
Up to TD 4.2 we enabled message yielding for the whole form window while looping through the records.
Starting with TD 7.4.1 we had to enable message yielding for the internal parent of the form windows (which is something between the title bar of the form window and its contents).
We have a push button pbCancel. If you click this button, the window variable w_bCancel is set to TRUE.
We do only continue the loop, if w_bCancel is FALSE.
Don't forgett to disable message yielding after this.
TD 4.2 code:
Code: Select all
Set w_bCancel = FALSE
Call SalYieldStartMessages( hWndForm )
While not w_bCancel and SqlFetchNext()
! display the record
Call SalYieldStopMessages()
Code: Select all
Set w_bCancel = FALSE
Call SalYieldStartMessages( GetParent( hWndForm ) )
While not w_bCancel and SqlFetchNext()
! display the record
Call SalYieldStopMessages()
Code: Select all
Library name: USER32.DLL
Function: GetParent
Description:
Export Ordinal: 0
Returns
Window Handle: HWND
Parameters
Window Handle: HWND
Rainer
Who is online
Users browsing this forum: [Ccbot] and 1 guest