Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the last SQL error?
Message
 
 
To
21/09/2011 09:32:00
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01524131
Message ID:
01524134
Views:
63
>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
>
The only way is to fix DoSelect procedure to return information about the error.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform