TfrxADOdatabase object
Hi,
I have a report that has some TfrxADOdatabase objects placed on "Data" page.
I need to modify at runtime the DatabaseName property of these objects from within the code.
Below is an example:
pFormReports->Report->Clear();
pFormReports->Report->LoadFromFile(path);
TfrxDataPage* pData = NULL;
for(int i = 0; i < pFormReports->Report->PagesCount; i++)
{
if(pFormReports->Report->Pages->Name == "Data");
{
pData = (TfrxDataPage*)pFormReports->Report->Pages;
break;
}
}
if(pData != NULL)
{
for(int i = 0; i < pData->ComponentCount; i++)
{
ShowMessage(pData->Components->Name);
}
}
For some reason pData->ComponentCount returns 0 although there is a TfrxADOdatabase object on "Data" page.
So basically I would need to get all TfrxADOdatabase objects from "Data" page and change at runtime DatabaseName property.
Thanks.
I have a report that has some TfrxADOdatabase objects placed on "Data" page.
I need to modify at runtime the DatabaseName property of these objects from within the code.
Below is an example:
pFormReports->Report->Clear();
pFormReports->Report->LoadFromFile(path);
TfrxDataPage* pData = NULL;
for(int i = 0; i < pFormReports->Report->PagesCount; i++)
{
if(pFormReports->Report->Pages->Name == "Data");
{
pData = (TfrxDataPage*)pFormReports->Report->Pages;
break;
}
}
if(pData != NULL)
{
for(int i = 0; i < pData->ComponentCount; i++)
{
ShowMessage(pData->Components->Name);
}
}
For some reason pData->ComponentCount returns 0 although there is a TfrxADOdatabase object on "Data" page.
So basically I would need to get all TfrxADOdatabase objects from "Data" page and change at runtime DatabaseName property.
Thanks.
Comments
OK, I came up with this solution:
for(int i = 0; i < pFormReports->Report->DataSets->Count; i++)
{
cls = pFormReports->Report->DataSets->Items->DataSet->ClassName();
if(cls == "TfrxADOQuery")
{
TfrxADOQuery* pQuery = dynamic_cast<TfrxADOQuery*>(pFormReports->Report->DataSets->Items->DataSet);
cls = pQuery->Database->ClassName();
if(cls == "TfrxADODatabase")
{
TfrxADODatabase* pADO = dynamic_cast<TfrxADODatabase*>(pQuery->Database);
ShowMessage(pADO->DatabaseName);
}
}
}