TfrxADOdatabase object

edited 7:04PM in FastReport 4.0
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.

Comments

  • edited 7:04PM
    valos wrote: »
    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.

    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);
    }
    }
    }

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.