Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the last SQL error?
Message
From
21/09/2011 10:08:44
 
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:
01524138
Views:
49
>>>>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.
>>
>>Jim Nelson gave me the answer..
>>
>>He said:
>>
>> Catch to loException
>>
>> loException is an exception object (look it up in help file)
>>
>>
>>So, now my final code looks like this and works EXACTLY like needed.
>>
>>
>>Try
>>
>>	lnReturn = DoDefault(lcSelect)
>>
>>Catch to loException
>>
>>	This.Seterror(This.Class + '.' +  loException.Procedure + ':' + loException.Message, loException.ErrorNo)
>>
>>	lnReturn = -1
>>
>>Endtry
>>
>
>Good point about exception - does it catch all the details?


The Exception object that it creates contains TONS of useful data:

Here are the properties on the Exception object:
.BaseClass
.Class
.ClassLibrary 
.Comment 
.Details 
.ErrorNo 
.LineContents 
.LineNo 
.Message 
.Name 
.Parent 
.ParentClass 
.Procedure 
.StackLevel 
.Tag 
.UserValue 
.
Previous
Reply
Map
View

Click here to load this message in the networking platform