Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to NOT stop the Select SQL?
Message
 
 
À
28/01/2005 08:44:58
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Divers
Thread ID:
00980904
Message ID:
00981699
Vues:
78
Hi Mike,

I just found, that it was already this way. Originally I put my code in Form's Error method, but later I understood, that Biz object Error method is the place to put it. So here is my current BizObj Error method:
LPARAMETERS tnError, tcMethod, tnLine, tcSys16, toErrObj, tcMessage
IF m.tnError = 1839 && SQL-Select was cancelled	
   
	IF VARTYPE(m.plStop) = "L" AND m.plStop 
		* Have we stopped already?
		this.lRepeatRequery = .f.
	ELSE
		* RETRY  - doesn't work
		this.lRepeatRequery = .t.
	ENDIF
ELSE
	DODEFAULT(m.tnError, m.tcMethod, m.tnLine, m.tcSys16, m.toErrobj, m.tcMessage)
ENDIF
And here is an excerpt from the PopulateCursor method:
LOCAL lnRequeryResult 
	lnRequeryResult = .REQUERY() && requeries the initially selected alias
    * I found, that requery returns -3 if interrupted - this is not documented in the Help
    
    DO WHILE .lRepeatRequery = .t. and m.lnRequeryResult < 0 && the user tried to stop it 
        lnRequeryResult = .requery()       
    *    .lRepeatRequery = .f.
    ENDDO     
    
    ** What if requery returns 0 - it means some problems with the view 
>By the way, Nadya
>
>This code has a problem.
>
>
LPARAMETERS nError, cMethod, nLine, tcSys16, toErrObj
>IF m.nError = 1839 && Requery cancelled	
>
>	IF VARTYPE(m.plStop) = "L" AND m.plStop
>		* Have we stopped already?
>	ELSE
>		RETRY
>	ENDIF
>ELSE
>	DODEFAULT(nError, cMethod, nLine, tcSys16, toErrObj)
>ENDIF
>
>I think you should code it like this...
>
>
LPARAMETERS m.tnError, m.tcMethod, m.tnLine, m.tcSys16, m.toErrObj
>IF m.tnError = 1839 && Requery cancelled	
>
>	IF VARTYPE(m.plStop) = "L" AND m.plStop
>		* Have we stopped already?
>	ELSE
>		RETRY
>	ENDIF
>ELSE
>	DODEFAULT(m.tnError, m.tcMethod, m.tnLine, m.tcSys16, m.toErrObj)
>ENDIF
>
>Because! nError with or without the mdot is possibly a field name in some naming conventions. You can run into a conflict. Further, you are mixing different types of notations. nError and toErr. Every parameter is supposed to be prefaced with "t". You can and IMO should name them properly.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform