Crystal report 10 ( Modify database location at runtime using CrystalRuntime.Application.10 )
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
Hi All. With Crystal report 10 I go to generate the report file and through the DLL to runtime I go to modify the logon parameters.... With this code I go to set up the parameters of logon of the report...but there is a problem when I set password ConnectionProperty has not been set..only password connection property....:mad:
void CDlgRptConnectionProperty::OnBnClickedOk()
{
_bstr_t bstParameterName,
bstParameterValue;
_variant_t vtValue;IConnectionPropertyPtr pConnectionProperty = NULL; IDatabaseTablesPtr pDatabaseTables = NULL; INameValuePairsPtr pNameValuePairs = NULL; IDatabasePtr pDatabase = NULL; \_bstr\_t bstConnection; HRESULT hr; try { // Puntatore interfaccia tabelle pDatabaseTables = m\_pReport->GetDatabase()->GetTables(); // Puntatore parametri di connessione tabella IDatabaseTablePtr pDatabaseTable = pDatabaseTables->GetItem(1); pNameValuePairs = pDatabaseTable->GetConnectionProperties(); if( (m\_typeRptConnection == ModifyConnectionADO) || (m\_typeRptConnection == ModifyConnectionDAO) ) { // Ciclo sui parametri del report for( int nIndexParam = 0; nIndexParam < m\_lstParameterConnection.GetItemCount(); nIndexParam++ ) { // Nome e Valore parametro bstParameterName = m\_lstParameterConnection.GetItemText(nIndexParam,COL\_0); CString sParameterName(bstParameterName.GetBSTR()); if( sParameterName.Compare(ADO\_PARAMETER\_5) != 0 ) { // Valore parametro bstParameterValue = m\_lstParameterConnection.GetItemText(nIndexParam,COL\_1); }else { // Password utente bstParameterValue = GetUserPassword(nIndexParam,COL\_1); } // Modifica parametro connessione IConnectionPropertyPtr pConnectionProperty = pNameValuePairs->GetItem(bstParameterName); pConnectionProperty->PutValue(bstParameterValue); }//:End for parametri report }else if( (m\_typeRptConnection == ReplaceConnectionADO) || (m\_typeRptConnection == ReplaceConnectionDAO) ) { // Cancellazione parametri esistenti pNameValuePairs->DeleteAll(); // Nome dll da utilizzare \_bstr\_t bstDllName; if( m\_typeRptConnection == ReplaceConnectionADO ) bstDllName = DLL\_ADO; else if( m\_typeRptConnection == ReplaceConnectionDAO ) bstDllName = DLL\_DAO; m\_pReport->GetDatabase()->GetTables()->GetItem(1)->DllName = bstDllName; // Ciclo sui parametri for( int nIndexParam = 0; nIndexParam < m\_lstParameterConnection.GetItemCount(); nIndexParam++ ) {