Hi,
at the moment I am testing the ADODB functionality and for me it works great.
My question is what is the best way to check if a insert, update or delete operation
is error-free?
Thanks for your support.
Axel
Printable View
Hi,
at the moment I am testing the ADODB functionality and for me it works great.
My question is what is the best way to check if a insert, update or delete operation
is error-free?
Thanks for your support.
Axel
Ciao Axel,
that area is still to be implemented.
I also use a lot ADODB at work and I too need error checking. So I will start to check about it.
Eros
PS: mask edit is still on the table, sorry.
Ciao Eros,
sounds good :p
Thank you for the fast answer.
Axel
I think I will have a solution in few days that I can post here to test.
Actually I'm facing the problem that every single ADODB operation can fire an error but I'm only able to catch the last one.
So, if an operation composed by 3 steps fails at first or second step but third is OK, I get no error.
An example, the following code taken from \thinBasic\SampleScripts\ADODB\ example is composed by 4 pRecordset calls (record count plus 3 field data retrieve).
If error occurs in one of the first 3 calls but the 4th is ok, I get no error.
I can store errors as an array of errors but it would be complex to handled them.Code:PrintL _
lRecCount,
pRecordSet.RecordCount,
pRecordset.CollectS("ISBN"),
pRecordset.CollectN("Year Published"),
pRecordset.CollectS("Title")
Anyway, thinking. Maybe I will just release catching last error and then I will refine it in some way.
Ideal would be to have TRY/CATCH in thinBasic but so far I found implementing it quite difficult considering the interpretative nature of thinBasic.
Will see.
Dear Axel,
I've developed something that can be a start.
I've modified all internal ADODB functionality in such a way to intercept errors at any level.
All errors are stored into an internal Module repository in such a way programmer can check and decide what to do.
Mainly I've developed 3 functions:
- AdoDb_Errors_Count: will return number of errors so far intercepted
- AdoDb_Errors_Clear: will clear internal errors repository. Can be called whenever programmer wants to reset situation
- AdoDb_Errors_GetCode(Idx): will return error code in Idx position with Idx between 1 and AdoDb_Errors_Count
- AdoDb_Errors_GetDescription(Idx): will return error description in Idx position with Idx between 1 and AdoDb_Errors_Count
An example on how to use:
Attached an updated thinBasic_AdoDB module to put into \thinBasic\Lib\ substituting your current one.Code:'---Do whatever with ADODB ... then check if some error.
printl "-----"
printl "Errors found:", AdoDb_Errors_Count
if AdoDb_Errors_Count then
for lError = 1 to AdoDb_Errors_Count
printl AdoDb_Errors_GetCode(lError), AdoDb_Errors_GetDescription(lError)
next
end if
printl "-----"
AdoDb_Errors_Clear
As I said, this is just a start in order to have something.
I will see If I can develop something that react as an event.
Let me know if it works.
Ciao
Eros
Dear Eros,
sounds fantastic!!!!!
I'll test it asap and give you a feedback.
Many thanks
Axel
Dear Erol,
risrst tests, I use your code in a function and use this after the ADO-Operation with the ADO Example PGM.
No Errors.
Than I will insert a new record:
No error but also no new rrecord in the database.Code:Function ado_check()
'---Do whatever with ADODB ... then check if some error.
PrintL "-----"
PrintL "Errors found:", AdoDb_Errors_Count In %CCOLOR_FYELLOW
If AdoDb_Errors_Count Then
For lError = 1 To AdoDb_Errors_Count
PrintL AdoDb_Errors_GetCode(lError), AdoDb_Errors_GetDescription(lError) In %CCOLOR_FLIGHTRED
Next
End If
PrintL "-----"
AdoDb_Errors_Clear
WaitKey
End Function
Function new_rec()
' pRecordset.movefirst
' pRecordset.MoveLast
' pRecordset.addnew
' pRecordset.UpdateS("ISBN") = "ich 4711"
' pRecordset.UpdateN("Year Published") = 2016
' pRecordset.UpdateS("Title") = "Mein erster satz"
' pRecordset.Update
' PrintL "nach add new" In %CCOLOR_FLIGHTRED
pRS.Open "Titles", pConnection, %ADOPENKEYSET, %ADLOCKOPTIMISTIC, %ADCMDTABLE
pRs.addnew
pRs.UpdateS("ISBN") = "ich 4711"
pRs.UpdateN("Year Published") = 2016
pRs.UpdateS("Title") = "Mein erster satz"
pRs.Update
PrintL "nach add new" In %CCOLOR_FLIGHTRED
ado_check
End Function
If I change the code to produce an error ( bad table name) the function ado_check reports errors
but raise an error "FOR LERROR = 1 TO ADODB_ERRORS_COUNT"
I hope it's understandable and can help you
Greetings
Axel
Thanks for testing.
I will let you know.
Ciao Eros,
any news?
I have very great interest in these functions.
Thank you very much for your efforts,
Axel
Yes, Axel, sorry. I'm late.
In reality I already have a solution but not jet ready to give you new module.
I will try to give you a new module to test in few days, by this week-end I hope.
Eros