Problem Loading report from file (without data pipeline?)
Hi list,
I'm trying load a report from a file, save it to text, change some stuff
manually and then write it back to binary format.
What I need to do is parse the SQL and replace all "dbo." the
ReportBuilder added when used with an MSSQL database because the report
needs to work on other databases too (which do not necessarily have the
dbo schema).
Another point is that old versions of our software inserted the wrong
database alias and I need to correct that too.
I now created a new Delphi VCL project, added a TppReport on my main form
and tried to load an existing report using the following code:
ppReport1.Template.Filename = ReportFile;
ppReport1.Template.LoadFromFile;
but the ReportBuilder throws the following exception:
Error reading ppReport2.OnGetAutoSearchValues: Illegal property value
(The exact syntax may differ because I'm using the German version where
it's "Fehler beim Lesen von ppReport2.OnGetAutoSearchValues: Ung?ltiger
Eigenschaftswert").
Is this a result of not having a connected data pipeline associated with
the report before loading?
The things I want to do do not require a connections so I don't want to
create one.
Any help is greatly appreciated.
Kind regards,
Christoph
--- posted by geoForum on http://delphi.newswhat.com
I'm trying load a report from a file, save it to text, change some stuff
manually and then write it back to binary format.
What I need to do is parse the SQL and replace all "dbo." the
ReportBuilder added when used with an MSSQL database because the report
needs to work on other databases too (which do not necessarily have the
dbo schema).
Another point is that old versions of our software inserted the wrong
database alias and I need to correct that too.
I now created a new Delphi VCL project, added a TppReport on my main form
and tried to load an existing report using the following code:
ppReport1.Template.Filename = ReportFile;
ppReport1.Template.LoadFromFile;
but the ReportBuilder throws the following exception:
Error reading ppReport2.OnGetAutoSearchValues: Illegal property value
(The exact syntax may differ because I'm using the German version where
it's "Fehler beim Lesen von ppReport2.OnGetAutoSearchValues: Ung?ltiger
Eigenschaftswert").
Is this a result of not having a connected data pipeline associated with
the report before loading?
The things I want to do do not require a connections so I don't want to
create one.
Any help is greatly appreciated.
Kind regards,
Christoph
--- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.
Comments
This error most likely indicates that when this template was saved, it had a
reference to the OnGetAutoSearchValues event. Now when you are reloading
it, it has lost that reference even if the event is implemented. Take a
look at the following article on lost event handlers.
--------------------------------------------
Article: Troubleshooting Lost Event Handlers
--------------------------------------------
Let's assume you have created a report in Delphi and assign an event
handlers to the OnPreviewFormCreate event of the report. The event is
generated by Delphi as:
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
You then save the report to an RTM file 'Report1.RTM.' The events are
stored as references only, and so the RTM contains:
object ppReport1: TppReport
.
.
OnPreviewFormCreate = ppReport1PreviewFormCreate
end
You then go on to work on a different report. Saving it with under then
name 'Report2.RTM'. Only this time, before you save the report you change
the report component name to: rptOrders. Delphi automatically updates the
event declaration for OnPreviewFormCreate event to:
procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);
You then create two buttons on the form, one to load Report1 and preview,
the other to load Report2 and preview. When you run the app and click
Report1, you an error. This is because the Report1.RTM file contains a
reference to ppReport1PreviewFormCreate, a method which no longer exists (at
least with this name) in the form.
One answer is to load all your rtm files into the report component you will
be using for loading. Fix any errors, reassign any events that get cleared.
This will update your rtms to contain the proper event handler names.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I just created a completely empty report with no data pipelines, no
overwritten events, etc. and I'm still getting the same error message when
loading.
I then overwrote the event OnGetAutoSearchValues with an empty procedure -
same result. Deleting the empty event handler did not help either.
I event don't have any reference to ppReport2. My local variable is named
ppReport1, so where does that come from?
Regards,
Christoph
--- posted by geoForum on http://delphi.newswhat.com
If you are still getting the error, there must be a reference to that event
somewhere in your project. Try taking a look at the .dfm source and see if
it may be in there.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Yes, the event information is probably saved down in the template. Two
options...
1. Save the template as text by changing the Template.Format property, then
open the file using a text editor such as notepad and search for the event
reference.
2. Use the example below to load and view a template as text from a DB and
edit it that way.
http://www.digital-metaphors.com/tips/EditTemplatesAsText.zip
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
The report is stored in binary format, so I'm afraid that I won't get that
much information.
Whatever, I tried using a hex editor and that's what I found:
But that doesn't help me. There is something about
"OnGetAutoSearchValues", but I do not see anything inside the report
itself (when opened with the designer).
Regards,
Christoph
--- posted by geoForum on http://delphi.newswhat.com
Thank you for the example. I'm able to load the report as a binary stream
and convert it to text using ObjectBinaryToText().
That's all I need to do, I do not need to use "LoadFromFile()" then,
because I can replace everything in the text file.
Thanks for your time!
Regards,
Christoph
--- posted by geoForum on http://delphi.newswhat.com