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
Data Access Europe