Dynamic database name change
I've been using code from DM for sometime, Delphi 6, to set the dbxpress
database name after a report loads, but now that I'm using Delphi 2005
the datapipeline count is off by 1. Or the linked pipeline does not get
the database name change. If there are three tables the last table get
the eDesignError. "unable to fine table last_table_name in cache.'.
Is there some other code that I can be using or a different way to set
the database name after the report loads. This does not happen on all
reports, just some with multiple tables or a pipeline link. Or when
prompting for params.
Please help!!!
Dave
function TdmReportTemplateVolume.GetSQLObject(aReport: TppReport; var
aSQL: TdaSQL): Boolean;
var
lDataModule : TdaDataModule;
lDataView : TdaDataView;
Indx : Integer;
begin
aSQL := nil;
{get the datamodule}
lDataModule := daGetDataModule(aReport);
if (lDataModule <> nil) then
begin
for Indx := 0 to lDataModule.DataViewCount -1 do
begin
lDataView := lDataModule.DataViews[Indx];
// set the database name to the module db
if (lDataView <> nil) and (lDataView is TdaQueryDataView) then
aSQL := TdaQueryDataView(lDataView).SQL;
aSQL.DatabaseName := RbDbX.Params.Values['Database'];
end;
end;
Result := (aSQL <> nil);
end;
database name after a report loads, but now that I'm using Delphi 2005
the datapipeline count is off by 1. Or the linked pipeline does not get
the database name change. If there are three tables the last table get
the eDesignError. "unable to fine table last_table_name in cache.'.
Is there some other code that I can be using or a different way to set
the database name after the report loads. This does not happen on all
reports, just some with multiple tables or a pipeline link. Or when
prompting for params.
Please help!!!
Dave
function TdmReportTemplateVolume.GetSQLObject(aReport: TppReport; var
aSQL: TdaSQL): Boolean;
var
lDataModule : TdaDataModule;
lDataView : TdaDataView;
Indx : Integer;
begin
aSQL := nil;
{get the datamodule}
lDataModule := daGetDataModule(aReport);
if (lDataModule <> nil) then
begin
for Indx := 0 to lDataModule.DataViewCount -1 do
begin
lDataView := lDataModule.DataViews[Indx];
// set the database name to the module db
if (lDataView <> nil) and (lDataView is TdaQueryDataView) then
aSQL := TdaQueryDataView(lDataView).SQL;
aSQL.DatabaseName := RbDbX.Params.Values['Database'];
end;
end;
Result := (aSQL <> nil);
end;
This discussion has been closed.
Comments
the error. I can see it get set and can check the value later, just
that when the report runs it fails.
Dave
I do not think anything has changed that would affect that code. Very
strange.
As a test try running the same report in standard Delphi app - might be a
little easier to debug.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
It is not just one report, it's any report that has prompts for parms
and multiple tables.
In debugging the server, it always goes through the steps and sets
the database name, just that then the error pops up and I've lost
control to the rbserver widgets. How else can I ensure the table is in
the cache? Is there a TppReport property that would help?
Dave
The ReportVolume BeforePublishReport event can be used to obtain a reference
to the TppReport instance as well as the report paramters, session
parameters, and other relevant objects. The event includes a parameter
called aEventParams that is an object of type
TrsBeforePublishReportEventParams. This class is documented in the
RBServer.hlp.
ReportBuilder's data access environment (DADE) keeps an internal meta data
cache of the available tables and fields assoicated with the database. This
is done to speed performance. Make sure that all of the reports in the
application use the same database name. If they do not, then you might need
to clear the meta data cache. See article below. (Note: this is not a new
feature, the meta data cache has been place forever).
----------------------------------------
Tech Tip: Clearing the Meta Data Cache
----------------------------------------
There is a global meta data cache that the ReportBuilder uses to cache
information about the available database tables and fields. You can clear
the meta data cache using the following code.
uses
daMetaDataManager;
begin
gMetaDataManager.Clear;
end;
--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com