Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 35

Thread: ADODB Question

  1. #21
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hi Axel,

    I cannot replicate the error. I tried to execute more than once with different parameters but no error.
    Are you able to create a sample minimal script in which you replicate the problem?

    Thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #22
    Hi Erol,

    this is my example:

    Uses "Console"
    Uses "ADODB"
     
     
    Dim pConnection   As New ADODB_CONNECTION
    Dim sConn         As String
    Dim sSql          As String 
      '--------------------------------------------------------------
      Function select_record(ByVal pconn As ADODB_CONNECTION, ByVal sSSS As String)
        Dim pRS As New ADODB_RECORDSET
        pRs.CursorLocation = %ADUSECLIENT
        sSql = "select * from T_SSS where sss = " & "'" & sSSS & "';"
        pRs.OPEN sSql, pConn, %ADOPENDYNAMIC, %ADLOCKOPTIMISTIC, %ADCMDTEXT         
    
        If pRS.State = %ADSTATEOPEN Then  
        PrintL "Sätze gefunden: " & pRs.RecordCount
        
        End If   
        
        
        pRs.close
      
      
      End Function
      
      '----------------------------------
      Function Add_New_Record(ByVal pConn As ADODB_CONNECTION, ByVal sISBN As String, ByVal lYear As Long, ByVal sTitle As String)
      '----------------------------------
        Dim pRS As New ADODB_RECORDSET
        pRs.CursorLocation = %ADUSECLIENT
        sSql = "select * from Titles where ISBN = " & "'" & sISBN & "';"
        PrintL ssql
        
       'pRS.Open "Titles", pConn, %ADOPENKEYSET, %ADLOCKOPTIMISTIC, %ADCMDTABLE 
       pRs.OPEN sSql, pConn, %ADOPENDYNAMIC, %ADLOCKOPTIMISTIC, %ADCMDTEXT         
    
        If pRS.State = %ADSTATEOPEN Then  
        PrintL pRs.RecordCount
        If pRS.RecordCount = 1 Then
            pRs.UpdateS("ISBN")           = sISBN '& " " & Timer'"ich 4711" 
            pRs.UpdateN("Year Published") = lYear'2016  
            pRs.UpdateS("Title")          = sTitle'"Mein erster satz"
            pRs.update
          '---To check if there is ana arror, always use connection and ErrorsCount method
          If pConn.Errors.Count Then  
            PrintL "--> Fehler nach update" In %CCOLOR_FYELLOW
            PrintL "Error number..:", pConn.Errors(1).Number
            PrintL "Description...:", pConn.Errors(1).Description
            PrintL "Source........:", pConn.Errors(1).Source
            PrintL "SQLState......:", pConn.Errors(1).SQLState
            PrintL "NativeError...:", pConn.Errors(1).NativeError
            pConn.Errors.Clear                     
          End If              
     
          PrintL "update" In %CCOLOR_FLIGHTRED
         End If
     
     If pRS.RecordCount = 0 Then 
            pRs.addnew
            pRs.UpdateS("ISBN")           = sISBN '& " " & Timer'"ich 4711" 
            pRs.UpdateN("Year Published") = lYear'2016  
            pRs.UpdateS("Title")          = sTitle'"Mein erster satz"
            pRs.UpdateS("PubID")          = 69
            pRs.update
          '---To check if there is ana arror, always use connection and ErrorsCount method
          If pConn.Errors.Count Then  
            PrintL "--> Fehler nach insert" In %CCOLOR_FYELLOW
            PrintL "Error number..:", pConn.Errors(1).Number
            PrintL "Description...:", pConn.Errors(1).Description
            PrintL "Source........:", pConn.Errors(1).Source
            PrintL "SQLState......:", pConn.Errors(1).SQLState
            PrintL "NativeError...:", pConn.Errors(1).NativeError
            pConn.Errors.Clear                     
          End If              
     
          PrintL "insert" In %CCOLOR_FLIGHTRED
         End If
     
          
       
     
     
          PrintL "  pRecordSet.Close         :", pRS.CLOSE
           
        End If
     
     
      End Function
     
     
      '---------------------------------------------------------------
      ' Connection
      '---------------------------------------------------------------
     
     
        'sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & APP_SourcePath & "biblio.mdb"
        sConn = "Provider=sqloledb;Data Source=\\server\db;Initial Catalog=KNI2M;User Id=xxxxxx;Password=yyyyy ;" 
     
        '---Set connection string
        pConnection.ConnectionString = sConn
     
     
    '    PrintL "-Connection------------------------------------------"
        PrintL "  Opening ..."                    , pConnection.OPEN'(sConn) 
    '    PrintL "  pConnection.Connectionstring:"  , pConnection.Connectionstring
        PrintL "  pConnection.State           :"  , pConnection.State
        PrintL "  pConnection.Version         :"  , pConnection.Version
     
     
        PrintL "-Press a key to continue------------------------------" In %CCOLOR_FYELLOW
     
     
        '---To check if there is ana arror, always use connection and ErrorsCount method
        If pConnection.Errors.Count Then
          '---Show all errors in one go. 
          '---This function also clear internal errors collection
          PrintL pConnection.Errors.Msg
        End If
     
     
     
     
        If pConnection.State = %ADSTATEOPEN Then
       
    '      Add_New_Record(pConnection, "999999900", 9999, "Axels Test " & Date$(2) & " " & Time$(0))
           
           select_record(pConnection, "11000238") 
           
           select_record(pConnection, "11000237")
     
    '      PrintL "-Closing press a key-------------------------------------------" In %CCOLOR_FYELLOW
          'WaitKey
         
          PrintL "  pConnection.Close        :", pConnection.CLOSE
     
     
        Else
          PrintL "-It was not possible to open a connection-" In %CCOLOR_FLIGHTRED
        End If
     
     
        PrintL
        PrintL "-Press a key to finish-------------------------------"
        WaitKey
    
    Thanks for your assist.

    Axel

  3. #23
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Ciao Axel,

    got the same error, thanks.

    I need more time to understand why, it is a parsing problem in thinBasic Core engine.
    There are some "optimizations" during first execution of a function that are applied from the second execution on.
    Obviously I've made some error in there

    As a workaround, please try to add parenthesis to:
    pRs.OPEN sSql, pConn, %ADOPENDYNAMIC, %ADLOCKOPTIMISTIC, %ADCMDTEXT
    
    and change to
    pRs.OPEN(sSql, pConn, %ADOPENDYNAMIC, %ADLOCKOPTIMISTIC, %ADCMDTEXT)
    
    Here seems to work, let me know if it works also for you.
    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #24
    Hi Eros,

    first check works fine for me, many thanks for the workearound.

    Axel

  5. #25
    Hello Eros,

    i have to insert a value , e.g. 58.58 in a database money field. I'm loosing the cent, the value in the database is 58.
    i have test pRs.updateN, pRs.updateD and prs.updateD. Always the same result. Do you have any idea?

    Thank you for your support.

    Regards,

    Axel

  6. #26
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Here it seems working fine.
    Attached an example with a BIBLIO.MDB Access DB in which I pass a numeric with 2 decimals and insert a new record with currency, long integer and double numeric field

    Let me know if it works for you.
    Eros
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by ErosOlmi; 11-04-2017 at 07:04.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #27
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Just a wild shot from DB amateur - couldn't it be something related to regional settings for floating point separator character?


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  8. #28
    Dear All,

    Please excuse my late reply. Yes at first I am searching in the locale setup values.
    I have overlooked my own mistakes. It all works as expected if you do it right.

    But thank you very much for your support.

    Kind regards,

    Axel

  9. #29
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Great, happy it is working.

    I'm going on to implement new features for this module because I'm also using it at work.
    In next thinBasic updated it will be also fully documented.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #30
    Hi Erol,

    Some information for you. I have finished my first TB ADO Project. The program replaces a COBOL / ODBC application.
    I have ~ 2200 LOC. The program converts up to 80000 records per run. The old program was running up to 80 minutes,
    the new needs of this 20 minutes max.
    fantastic

    two things I have:
    -If I have a wrong field name in pRS.update("xxx") I get no error message
    -if eg. the target field in pRS.update is a string with 20 digits and I set a value with 15 digits I get no error and teh field value is not set

    Thank you for your fantastic work!

    kind regards,

    Axel

Page 3 of 4 FirstFirst 1234 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

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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