Template being Loaded on FormCreate Causes AV
Hi,
I'm running Win2000/D6.2/RB7
This problem apparently existed in RB6.03 but the exception was handled. In
RB7 it's not being handled and I get an AV.
It's trying to open the dataset for my template on the form.create event.
The error finally occurs in the code below on the line:
FDataLink.DataSet.Open;
-----------------------------------------------
{ TppDBPipeline.OpenDataSet }
procedure TppDBPipeline.OpenDataSet;
begin
if (FDataSet <> nil) and (csDestroying in FDataSet.ComponentState) then
Exit;
FDataSet := FDataLink.DataSet;
if (FDataSet <> nil) then
FDataSet.FreeNotification(Self);
if FOpenDataSource and (FDataLink.DataSet <> nil) then
try
FDataLink.DataSet.Open;
except on E: Exception do
raise EDataError.Create(E.Message);
end;
end; {procedure, OpenTheDataPipeline}
------------------------------------------------
Thanks,
--
Ben Hoffman
Programmer / Analyst
Sirs Publishing, Inc.
1-800-232-7477, Ext. 797
benh@sirs.com
I'm running Win2000/D6.2/RB7
This problem apparently existed in RB6.03 but the exception was handled. In
RB7 it's not being handled and I get an AV.
It's trying to open the dataset for my template on the form.create event.
The error finally occurs in the code below on the line:
FDataLink.DataSet.Open;
-----------------------------------------------
{ TppDBPipeline.OpenDataSet }
procedure TppDBPipeline.OpenDataSet;
begin
if (FDataSet <> nil) and (csDestroying in FDataSet.ComponentState) then
Exit;
FDataSet := FDataLink.DataSet;
if (FDataSet <> nil) then
FDataSet.FreeNotification(Self);
if FOpenDataSource and (FDataLink.DataSet <> nil) then
try
FDataLink.DataSet.Open;
except on E: Exception do
raise EDataError.Create(E.Message);
end;
end; {procedure, OpenTheDataPipeline}
------------------------------------------------
Thanks,
--
Ben Hoffman
Programmer / Analyst
Sirs Publishing, Inc.
1-800-232-7477, Ext. 797
benh@sirs.com
This discussion has been closed.
Comments
which would cause the query to be executed when the template was loaded.
Download the latest ASTA plugin which has ben tested with RB 7 and ASTA 3.
http://www.digital-metaphors.com/tips/daASTA.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
We are using DataSnap and Oracle8i, so I don't think that this would apply.
Ben
don't see anything in the plugins that would cause this. Regardless, the
pipeline should not open the dataset when the template is loaded. Do you
have any event handlers that would cause the query to be opened or the
datapipeline to open the dataset? There is a Datapipeline.OpenDatasoure
property that you can try setting to false to see who is trying to open the
datasource. Point your library path to RBuilder\Source and place a
breakpoint in ppDBPipe.pas in the TppDBPipeline.OpenDataSet routine. Check
the call stack to see how is triggering the open call.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I am not using DADE and there are no other events.
When I try to set the Datapipeline.OpenDatasource to false, I get an error
in TppTemplate.CheckDatabaseSettings that the TemplateField is of the wrong
type. That is because it retrieves the DataBaseSettings.TemplateField as
dtNotKnown.
I don't think that this helps because if I look at the call stack with
Datapipeline.OpenDatasource = false, it still tried to load the data ahead
of time.
In any case, the call stack (with Datapipeline.OpenDatasource = True) is as
follows (The bottom item is my procedure of course):
TppDBPipeline.OpenDataSet
TppDataPipeline.Open
TppTemplate.LoadFromSource(stDataBase)
TppTemplate.Load
TppCustomReport.Loaded
TppReport.Loaded
DisplayForms1099(???)
Ben
template in the form create event and called print. It loaded and printed
with no problems.
You say that that the field type is unknown. What does your code to load the
template look like? Then check to make sure that the string you have set in
the Report.Template.DatabaseSettings.TemplateField matches the field name
for the field in your database. There shouldn't be an AV when it fails
though, it should raise an exception and tell you what the problem is, this
is the behavior we are getting here. Can you create an example that we can
run here that shows the problem? Send it to support@digital-metaphors.com
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks,
Ben Hoffman
Programmer / Analyst
Sirs Publishing, Inc.
1-800-232-7477, Ext. 797
benh@sirs.com
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
to database. This means that when the report is loaded, it tries t load the
template form the database. This would be bad, unless you are usign the
report explorer and have the template in a database ready to b loaded or
saved. If the data access has not been configured, then you must wait before
trying to set these properties until you have the template data access
components configured to support the SaveAsTemplate property. Set
SaveAsTemplate to false at delphi design time and the problem will go away
when you create the form.
BTW, it's not an AV, its an exception that gets raised. This is better than
an AV because you can handle the exception at runtime.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com