Setting database at runtime

edited 10:14PM in FastReport 3.0
Fast report version 3.09
Borland Delphi 7


In my application I load load reports at runtime and want to connect queries on the dialog page (in fr3 file) to an existing database connection at runtime. Since the queries in reports are cross-database compatible it's nice if I could develop reports separate from application, and then just load that custom fr3 in runtime.

A solution in v2.5 wat to set TfrxDBXQuery.Query.SQLConnection, but that does not work in v3.
If I set:
TfrxDBXQuery.Database:=nil;
TfrxDBXQuery.Query.SQLConnection:=MyExistingConnection;

then PrepareReports (more precisely TfrxDBXQuery.BeforeStartReport) overrides that and sets TfrxDBXQuery.Query.SQLConnection to nil (because TfrxDBXQuery.Database is nil) and then error "SQLConnection property missing" is raised.

Even if I accept that another connection to the database is required for generating a report, and I set all TfrxDBXQuery properties at runtime, there is another problem. I can not leave TfrxDBXDatabase.DriverName blank (as I can in plain TSQLConnection), which means, that the dbxdrivers.ini is required at every client site. And TfrxDBXDatabase.Database is ReadOnly, so I can't set that at runtime either.

Any suggestions short of modifying frxDBXComponents.pas?

brgds
Andrej

Comments

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.