Unknown Database Error
Hi,
We have two apps connect to the same set of tables for report designer.
These two apps use different Database Names. When I try to run the reports
from one app that were designed using the other app, it gives me an Unknown
Database error and give me the Database in the other app. Is there a way to
fix this so that it uses the database properties of the designer component
of the running app rather than the designing app?
Cheers!
Trhia
We have two apps connect to the same set of tables for report designer.
These two apps use different Database Names. When I try to run the reports
from one app that were designed using the other app, it gives me an Unknown
Database error and give me the Database in the other app. Is there a way to
fix this so that it uses the database properties of the designer component
of the running app rather than the designing app?
Cheers!
Trhia
This discussion has been closed.
Comments
The Database information is saved down in the Report Template when designing
a report. You will either need to change the name of the database used in
your second app to match the one in your first one, or manually edit the
template files using the OnLoadEnd Event. See the article below on how to
create and use this event to change any published report properties as you
load them.
-------------------------------------------------
Tech Tip: How to use the OnLoadEnd public event
-------------------------------------------------
This tech tip explains how to control report property settings when saved
reports are loaded by assigning an event handler to the OnLoadEnd event of
the Report.Template object.
The first thing we need to to is to declare the an event handler for the
OnLoadEnd event:
private
procedure LoadEndEvent(Sender: TObject);
Then we need to assign the event handler when the form or datamodule
containing the report component is created:
procedure TForm1.FormCreate(Sender: TObject);
begin
ppReport1.Template.OnLoadEnd := LoadEndEvent;
end;
Next we need to implement the event handler, setting the property values of
the report:
procedure TForm1.LoadEndEvent(Sender: TObject);
begin
ppReport1.AllowPrintToArchive := True;
end;
Any published properties of a report component which is used to load saved
reports can be restored to the necessary settings using this technique.
When a saved report is loaded, the published properties of the report are
set the values as they exist in the saved version. These settings depend on
the state of the report component when the report was initially saved, and
they may not be the ones you want. By assigning this event handler, we can
control the report component property values regardless of the values which
exist in the saved version of the report.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for the response. It tried the second option because I can not
change the name of the database I use. This is due to the second app also
have quite a number of saved reports already as well. The users of the
second app decided that they want to be able to modify and run the reports
from the other app hence the problem I am encountering at the moment.
I tried to follow the article but the problem still occurs. Here is the
code that I used. I must have done it incorrectly:
procedure TReportDM.LoadEndEvent(Sender: TObject);
var aList : TList;
i : integer;
aPipeLine : TppBDEPipeline;
begin
aList := TList.Create;
Report.GetRBDataModulePipelines(aList);
for i := 0 to aList.Count - 1 do
begin
aPipeLine := TppBDEPipeline(aList[i]) ;
if assigned(aPipeline.DataSource) and
assigned(aPipeLine.DataSource.Dataset) then
begin
TQuery(aPipeLine.DataSource.DataSet).DatabaseName :=
ApplicationsDM.AppDatabase.DatabaseName;
end;
end;
FreeAndNil(aList);
end;
procedure TReportDM.DataModuleCreate(Sender: TObject);
begin
Report.Template.OnLoadEnd := LoadEndEvent;
end;
Any help would be greatly appreciated!
Cheers!
Trhia
Be sure your report does not reside on a DataModule. Try moving the report
object to a form and see if this changes anything. Regardless, it is never
a good idea to try to run a report on a DataModule.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I tried but no luck .... I couldn't even get any of the reporting
functions to run when I transferred them to a form. The report object is
part of the designer/explorer objects to do our reporting functions to
design/run/print and preview reports. When I transferred all the
components and methods to the form, nothing worked anymore. When I run the
report, I merely call ReportExplorer.PrintPreview or ReportExplorer.Print
and passing in the folderID and name of the report. They all worked fine in
the data module but now it doesn't from the Form. We had to do it this way
because our app displays a tree view menu system for reports and forms
combined. And so we use a DataModule to perform the functions as the user
selects them.
Yesterday, when I had it in the DataModule, debugging in the LoadEndEvent
shows me that the DatabaseName of the datapipeline was set to an empty
string. (Just letting you know in case it's relevant ...)
Help!
Cheers!
Trhia