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.
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