Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strange Error Message
Message
 
 
À
24/03/2011 21:39:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01504918
Message ID:
01504922
Vues:
61
Change PARAMETERS to LPARAMETERS
and add

LOCAL lnResult
lnResult = 0

at the top of your code

>I have the following code
>
>*sql_execute
>PARAMETERS tnConnection,tcSql,tcOutput
>
>IF EMPTY(tcSql)  && Processing via an SQLPREPARE() statement
>	tcSql = " "   && So Error Routine has character value
>	lnResult = SQLEXEC(tnConnection)
>ELSE
>	IF EMPTY(tcOutput)
>		lnResult = SQLEXEC(tnConnection,tcSql)
>	ELSE
>		lnResult = SQLEXEC(tnConnection,tcSql,tcOutput)
>	ENDIF
>ENDIF
>
>IF lnResult = -1 
>	=AERROR(aTmpError)
>	lnStack = ASTACKINFO(aTmpStack)
>
>	IF TYPE("app_global") <> "O"
>		app_global = CREATEOBJECT('custom')
>		app_global.addproperty("app_name","Insert App Name")
>		app_global.addproperty("employee","RPUPKO")
>	ENDIF
>		
>	INSERT INTO spotlight_errors(application,sql_statement,error_msg,dt_error,userid,stack) VALUES;
>	    (app_global.app_name,tcSql,aTmpError[2],DATETIME(),app_global.employee,this.array_to_char('aTmpStack'))
>	USE IN (SELECT('spotlight_errors'))
>
>	IF this.showerror
>		=MESSAGEBOX(aTmpError[2],0,PROGRAM(aTmpStack[ALEN(aTmpStack,1)-1,1]))
>		SET STEP ON 
>	ENDIF
>	RETURN .F.
>ENDIF
>
>One of the records in the error log has the error message Variable 'LNRESULT' is not found."
>
>I've never been able to reproduce this error and it's quite possible that the environment would actually absorb it and allow processing to continue. So if this error were generated by IF lnResult = -1 the record would actually get written.
>
>What I don't understand is how the variable could not have a value. Can anybody give me a set of circumstances where this variable does not exist when AERROR() is called?
>
>One possibility is that the error was actually generated in some other module and properly handled there. It could have been the last error generated so that's what AERROR() would find. In which case, for this module it really has a value of -1 so I'm supposed to go into the error handling portion of the code. The problem with that is the value is being assigned by the SQLEXEC() statements. If that statement resulted in a value of -1, why doesn't AERROR() return the ODBC errors I'm expecting.
>
>I've checked with the users of the system and nobody has noticed any unexpected results, so it appears that the final processing is correct. But this is driving me crazy(ier). Any and all suggestions gratefully accepted.
>
>..........Rich
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform