Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Q: ADO, RDO, OLE DB, what to use?

  1. #11
    Join Date
    Feb 2009
    Location
    Boxtel, The Netherlands
    Posts
    967

    Default Re: Q: ADO, RDO, OLE DB, what to use?

    Peter,

    it is also some time ago that I was using Crystal but here is a snippet of code I've used:

    Code:
    
       Procedure InitializeODBConnection Handle hoReport
          Boolean bAttached 
          Handle hoConnectionProperties 
          Variant vConnectionProperties 
          String sTable 
          Integer iTableItem iTableCount
          Handle[] hoTables
          Handle hoDatabaseTable
          Boolean bOk
              
          Get TableObjects of hoReport to hoTables
          Move (SizeOfArray(hoTables)) to iTableCount
          For iTableItem from 0 to (iTableCount-1)
             Get ComName of hoTables[iTableItem] to sTable
             Get GetTableObjectByName of hoReport sTable to hoDatabaseTable
             Move (hoDatabaseTable) to bOk
             If bOk Begin
                Get create U_cCrystalConnectionProperties to hoConnectionProperties
                Get ComConnectionProperties of hoDatabaseTable to vConnectionProperties
                Set pvcomObject of hoConnectionProperties to vConnectionProperties
                Get IsComObjectCreated of hoConnectionProperties to bAttached
                    
                If (not(bAttached)) Begin
                   Error DFERR_CRYSTAL_REPORT "ConnectionProperties"
                End
                Send ComDeleteAll of hoConnectionProperties
                Send ComAdd of hoConnectionProperties "Provider" "SQLOLEDB"
                Send ComAdd of hoConnectionProperties "Data Source" (psServerName(Self))  //  <-- You have to determine yourself
                Send ComAdd of hoConnectionProperties "Initial Catalogue" (psDataBase(Self))
                Send ComAdd of hoConnectionProperties "User ID" (psUsername(Self))
                Send ComAdd of hoConnectionProperties "Password" (psPassWord(Self))            
                Send ComAdd of hoConnectionProperties "Integrated Security" 0            
                    
                Send destroy of hoConnectionProperties
             End
          Loop
       End_Procedure
    
    
       Procedure DoInitializeODBConnection Handle hoReport  // <---- Call this in OnInitializeReport
          Integer iReportCount iReportItem
          Handle[] SubReportArray
          //
          Send InitializeODBConnection hoReport
          //
          Get SubReportObjects of hoReport to SubReportArray
          Move (SizeOfArray(SubReportArray)) to iReportCount
          For iReportItem from 0 to (iReportCount-1)
             If (SubReportArray[iReportItem]) Begin
                Send InitializeODBConnection (SubReportArray[iReportItem])
             End
          Loop
       End_Procedure
    Kind regards,

    Hans van de Laar
    www.datascore.nl
    www.vdfstructureviewer.com

    “You will only fail to learn if you do not learn from failing.” – Stella Adler

  2. #12
    Join Date
    Feb 2009
    Location
    Boston, MA USA
    Posts
    737

    Default Re: Q: ADO, RDO, OLE DB, what to use?

    Thank you, Hans.... this solved my issue and now I'm on to another snag with security that I have a resource to help me with. I appreciate it!

    Peter

    >EDIT (Added to original post) ------------
    Hans, the security issue I mentioned above caused me to change your code to solve my security issue:
    I found that you were using a (False) zero value on Integrated Security, and when I changed it to (True) 1, I no longer needed the reference to user and password and felt that this is more appropriate security because a crystal report is a readonly tool.

    Also, I wanted to compliment you on your code.... I have seen a few versions of this, and I like your version the most due to both readability/clear coding/simplicity, and the use of properties instead of a data file or INI file containing info.

    Thank you so much.
    Last edited by ApplauseBoston; 10-Jun-2016 at 11:37 AM.
    Peter A Donovan
    Applause Software
    Wakefield, MA USA
    (781) 548-9420
    www.ApplauseSoftware.Com

  3. #13
    Join Date
    Mar 2009
    Location
    Geelong, Australia
    Posts
    33

    Default Re: Q: ADO, RDO, OLE DB, what to use?

    Hi Guys,
    I am trying to re direct the DataFlex sourced crystal reports to use a SQL connection using DataFlex 18.2

    Starting with Hans van de Laar Code from and calling it from Procedure OnInitializeReport
    I get the location and login box for the files.

    Click image for larger version. 

Name:	CrystalLoginDetails.JPG 
Views:	37 
Size:	31.7 KB 
ID:	12864

    What am I missing our here?
    Where should I have connections.ini or ConnectionIds.Ini located?

    Code:
       Set pbAutoLocateDFFiles to False
    
    
       //Hans van de Laar Code
       Procedure InitializeODBConnection Handle hoReport
          Boolean bAttached 
          Handle hoConnectionProperties 
          Variant vConnectionProperties 
          String sTable 
          Integer iTableItem iTableCount
          Handle[] hoTables
          Handle hoDatabaseTable
          Boolean bOk
              
          Get TableObjects of hoReport to hoTables
          Move (SizeOfArray(hoTables)) to iTableCount
          For iTableItem from 0 to (iTableCount-1)
             Get ComName of hoTables[iTableItem] to sTable
             Get GetTableObjectByName of hoReport sTable to hoDatabaseTable
             Move (hoDatabaseTable) to bOk
             If bOk Begin
                Get create U_cCrystalConnectionProperties to hoConnectionProperties
                Get ComConnectionProperties of hoDatabaseTable to vConnectionProperties
                Set pvcomObject of hoConnectionProperties to vConnectionProperties
                Get IsComObjectCreated of hoConnectionProperties to bAttached
                    
                If (not(bAttached)) Begin
                   Error DFERR_CRYSTAL_REPORT "ConnectionProperties"
                End
                Else Begin
                   Send ComDeleteAll of hoConnectionProperties
                   Send ComAdd of hoConnectionProperties "Provider" "SQLOLEDB"
                   Send ComAdd of hoConnectionProperties "Data Source" "THERM04\MEDIFLEX" // (psServerName(Self))  //  <-- You have to determine yourself
                   Send ComAdd of hoConnectionProperties "Initial Catalogue" "MediFlex" //(psDataBase(Self))
                   Send ComAdd of hoConnectionProperties "User ID" "" //(psUsername(Self))
                   Send ComAdd of hoConnectionProperties "Password" "" //(psPassWord(Self))            
                   Send ComAdd of hoConnectionProperties "Integrated Security" 1 //0            
                 End
                Send destroy of hoConnectionProperties
             End
          Loop
       End_Procedure
       
       Procedure DoInitializeODBConnection Handle hoReport // <---- Call this in OnInitializeReport
          Integer iReportCount iReportItem
          Handle[] SubReportArray
    
    
          //
          Send InitializeODBConnection hoReport
          //
          Get SubReportObjects of hoReport to SubReportArray
          Move (SizeOfArray(SubReportArray)) to iReportCount
          For iReportItem from 0 to (iReportCount-1)
             If (SubReportArray[iReportItem]) Begin
                Send InitializeODBConnection (SubReportArray[iReportItem])
             End
          Loop
       End_Procedure
    
    
       Procedure OnInitializeReport 
          Forward Send OnInitializeReport  hoReport
    
    
          Send Destroy_Object of hoSQLConnection
          Send DoInitializeODBConnection hoReport
       End_Procedure // OnInitializeReport
    Last edited by DavidG; 17-Jun-2019 at 05:39 PM. Reason: VDF Version

Similar Threads

  1. Connect to SQL via OLE DB (ADO)
    By Thomas Murphy in forum Crystal Reports
    Replies: 6
    Last Post: 10-Oct-2011, 03:05 AM
  2. pdf ado stream
    By John Vermeer in forum Web & Mobile Applications
    Replies: 4
    Last Post: 28-Sep-2010, 07:54 AM
  3. ADO Close method
    By Tim Copenhaver in forum Windows Applications
    Replies: 4
    Last Post: 23-Apr-2008, 12:34 AM
  4. OLE Automation
    By HenryEgal in forum Windows Applications
    Replies: 2
    Last Post: 27-Feb-2006, 11:01 PM
  5. Multiples LOGINS => VDF drivers (ex. ODBC) and an external ADO (OLEDB)
    By Cesar Margarida in forum Windows Applications
    Replies: 4
    Last Post: 6-Jul-2005, 04:30 PM

Posting Permissions

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