Open table causes access violation/invalid pointer
Hi,
We are using RB 11.04 with Delphi 2009 and Windows XP.
We are experiencing an issue with having certain tables from our database
open and an access violation or invalid pointer error occurring. The
database we use is dbisam and every time we leave open certain tables and
print/view our reports either an access violation occurs or an invalid
pointer error occurs when we close the program. This also seems to happen
only when we are editing the dataview sql in our programs code. If we close
the table, or remove the section that edits the sql the reports will load
with no problem. I am curious if anyone else has experienced this, or if
there is some step were are missing when leaving tables open or editing the
sql. We have all of our main tables set to use optimistic locking so I
don't think that is an issue. Any help would be appreciated. I will leave
an example of the kind of code we use below.
Thanks,
Justin
**********
//This is where we edit the SQL. I know the TDASQLBuilder is the preferred
method but most of our reports use edited sql and we use our
//own custom screen to allow our customers to choose the fields they filter
by.
**********
SetReportSQL := false;
// If report is valid...
if ppReport <> nil then
begin
// Get query data view
daQueryDataView := GetReportQueryDataView(ppReport, strQueryDataView);
// If view is valid, get SQL; if SQL is valid, set SQL string
if daQueryDataView <> nil then with daQueryDataView do if SQL <> nil then
try
if not SQL.EditSQLAsText then
SQL.EditSQLAsText := True;
********************//Removing this section allows all reports to print
correctly*********************
SQL.SQLText.Text := strSQL;
OutOfSync;
SetReportSQL := True;
except
end;
end;
**********This is were we print the report*********
//leaving this table open will cause either an access violation error or
invalid pointer error
tblLocal.Open;
//loading the report twice also seems to cause problems. I do it here
twice just as an example. In our actual program, we load once for
//retrieving fields for filtering, and again later in our print procedure.
ReportExplorer.LoadReport('Equipment Listing', 25);
ReportExplorer.LoadReport('Equipment Listing', 25);
strSQL := GetReportSQL(Report);
SetReportSQL(strSQL, Report);
with Report do begin
Reset;
Parameters.Clear;
Parameters.Add('Metric', dtBoolean, false);
Parameters.Items['ppMetric'].AsBoolean := False;
// Preview or print report
AllowPrintToFile := true;
DeviceType := dtScreen;
Print;
end;
We are using RB 11.04 with Delphi 2009 and Windows XP.
We are experiencing an issue with having certain tables from our database
open and an access violation or invalid pointer error occurring. The
database we use is dbisam and every time we leave open certain tables and
print/view our reports either an access violation occurs or an invalid
pointer error occurs when we close the program. This also seems to happen
only when we are editing the dataview sql in our programs code. If we close
the table, or remove the section that edits the sql the reports will load
with no problem. I am curious if anyone else has experienced this, or if
there is some step were are missing when leaving tables open or editing the
sql. We have all of our main tables set to use optimistic locking so I
don't think that is an issue. Any help would be appreciated. I will leave
an example of the kind of code we use below.
Thanks,
Justin
**********
//This is where we edit the SQL. I know the TDASQLBuilder is the preferred
method but most of our reports use edited sql and we use our
//own custom screen to allow our customers to choose the fields they filter
by.
**********
SetReportSQL := false;
// If report is valid...
if ppReport <> nil then
begin
// Get query data view
daQueryDataView := GetReportQueryDataView(ppReport, strQueryDataView);
// If view is valid, get SQL; if SQL is valid, set SQL string
if daQueryDataView <> nil then with daQueryDataView do if SQL <> nil then
try
if not SQL.EditSQLAsText then
SQL.EditSQLAsText := True;
********************//Removing this section allows all reports to print
correctly*********************
SQL.SQLText.Text := strSQL;
OutOfSync;
SetReportSQL := True;
except
end;
end;
**********This is were we print the report*********
//leaving this table open will cause either an access violation error or
invalid pointer error
tblLocal.Open;
//loading the report twice also seems to cause problems. I do it here
twice just as an example. In our actual program, we load once for
//retrieving fields for filtering, and again later in our print procedure.
ReportExplorer.LoadReport('Equipment Listing', 25);
ReportExplorer.LoadReport('Equipment Listing', 25);
strSQL := GetReportSQL(Report);
SetReportSQL(strSQL, Report);
with Report do begin
Reset;
Parameters.Clear;
Parameters.Add('Metric', dtBoolean, false);
Parameters.Items['ppMetric'].AsBoolean := False;
// Preview or print report
AllowPrintToFile := true;
DeviceType := dtScreen;
Print;
end;
This discussion has been closed.
Comments
This is not a known behavior. If you trace into the ReportBuilder source
when the errors occur, what is causing the problem? Are you able to
successfully run the DBISAM demo included with ReportBuilder?
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
destructor TppRelative.Destroy;
begin
Destroying;
SetParent(nil);
FreeChildren;
FChildren.Free;
inherited Destroy;
end; {destructor, Destroy}
However, this is not very consistent. I have traced the problem previously
and it sometimes breaks at different points. The dbisam demo works
correctly. I just completed a sample project that I will send to your
support email. It displays the behavior I am talking about.
Thanks,
Justin