Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: ADODB Question

  1. #1

    ADODB Question

    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

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    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.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    Ciao Eros,

    sounds good
    Thank you for the fast answer.

    Axel

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    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.
           PrintL _
                  lRecCount,
                  pRecordSet.RecordCount, 
                  pRecordset.CollectS("ISBN"), 
                  pRecordset.CollectN("Year Published"), 
                  pRecordset.CollectS("Title")
    
    I can store errors as an array of errors but it would be complex to handled them.
    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.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    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:
    1. AdoDb_Errors_Count: will return number of errors so far intercepted
    2. AdoDb_Errors_Clear: will clear internal errors repository. Can be called whenever programmer wants to reset situation
    3. AdoDb_Errors_GetCode(Idx): will return error code in Idx position with Idx between 1 and AdoDb_Errors_Count
    4. 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:
      '---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
    
    Attached an updated thinBasic_AdoDB module to put into \thinBasic\Lib\ substituting your current one.

    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
    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #6
    Dear Eros,

    sounds fantastic!!!!!

    I'll test it asap and give you a feedback.

    Many thanks

    Axel

  7. #7
    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:
    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
    
    No error but also no new rrecord in the database.
    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

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    Thanks for testing.
    I will let you know.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #9
    Ciao Eros,

    any news?
    I have very great interest in these functions.

    Thank you very much for your efforts,

    Axel

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,187
    Blog Entries
    2
    Rep Power
    10
    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
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Page 1 of 4 123 ... LastLast

Similar Threads

  1. Question of the day ;)
    By Petr Schreiber in forum thinBasic General
    Replies: 8
    Last Post: 23-08-2010, 19:58
  2. C to TB question
    By Michael Clease in forum Other languages
    Replies: 2
    Last Post: 03-06-2010, 12:11
  3. gdi question
    By Lionheart008 in forum UI (User Interface)
    Replies: 6
    Last Post: 07-12-2009, 19:31
  4. UDT question
    By sandyrepope in forum thinBasic General
    Replies: 3
    Last Post: 18-02-2008, 22:33
  5. m15 question
    By kryton9 in forum M15 file format
    Replies: 4
    Last Post: 20-06-2007, 20:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •