Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the last SQL error?
Message
De
21/09/2011 09:32:00
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Getting the last SQL error?
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01524131
Message ID:
01524131
Vues:
112
Is there a way to get the error code and message of the last SQL error?

Here's my situation:

I call into a method and pass a SQL string which gets dynamically executed in the called method, but if it causes and error (i.e. if it has an invalid SQL syntax or a bad Order By clause), and then when I check AERRORS(), I get the error of the local call to the worker method, rather than the SQL error that I want to discover.

I cannot touch the called method code to modify it to handle this, since it is part of another framework that I cannot edit. I must find a way to handle this in my wrapper method.

Here is the code I have, but AERRORS() returns info about the call to DoSelect() and not the failure of the SQL statement that I passed in.
Try
	lnReturn = DoSelect(lcSQL)
Catch
	AError(laErrors)

	If laErrors(1) = 1832
		This.SetError(This.Class + ' SQL ERROR:' + laErrors(2), laErrors(1))
	Endif

	lnReturn = -1
Endtry
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform