Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting location in a Crystal Reports subreport from Delphi

Status
Not open for further replies.

goranm

Programmer
Dec 18, 2001
247
SE
Hello !

I have a problem with setting the location for my Crystal Reports subreports from my Delphi application.

I have seen some threads about this before but I haven´t been able to fix my problems.

When running the application we get an access violation.

I’m working with
Crystal Reports 8.5
Delphi5
Oracle7 (and Oracle8 for some customer)

We develop our reports against a test database and will be able to change the connection to another database at runtime so it effects both main report and subreports.

It is just for the ones with Oracle8 that I have the problem. For the other ones it works with the following code when calling the main report:

var
CrpPrint: TCRPE;

begin
CrpPrint:= TCRPE.Create(application);

CrpPrint.Connect.ServerName := ’DatabaseName’;
CrpPrint.Connect.UserID := ’UserId’;
CrpPrint.Connect.Password := ’Password’;
CrpPrint.ReportName := Path + Name of MainReport;
.
.
.
.
CrpPrint.Execute;
end;


If anyone have some sort of solution or workaround for this problem I will be very, very happy.

/Goran.
 
hi

In Report Designer, does the report open okay if you Set Location to Oracle 8.

I had the problem where I wanted to change servers at runtime, to the same database name and report name but couldn't get it to work.

I've got a feeling you wouldn't be able to change the db or server at runtime as I think the report is 'compiled' from report designer with the location determined. I'm could be very wrong here and open to feedback. Crystal does support Aliases in the designer but I didn't do too much research in to them so don't know if they would help.

If you get a solution, I'd be very interested to learn about it.

lou
p.s. I was using CR7 so don't know new features in v8.
 
hi, me again

If I'm right in the previous message, you will have to create 2 versions of your report. One with Set Location to Oracle 7 and the other Set Location to v8. In Delphi, check which database you're on and assign the appropriate report accordingly.

lou
 
Hi !

Thanks Lou for your answer.

Maybe I was not clear enough in my description.

The problem I have is when I want to switch from one database (alias) to another.
(But still in the same environment. Either Oracle7 or Oracle8)

For instance, I develop the report in an Oracle8 environment, and use a testdatabase called ”TEST_DB”, so both main report and subreport are set to that location.

Later when we run those reports in ”sharp” production I want to be able to set the location from my Delphi application to another database/alias called ”PROD_DB”.

I have seen some threads before where they suggest that you query the report and determine if it has any subreports or not. And if, you can point to each subreport and change the location.

So I wonder if that´s possible from Delphi and if it is I will be glad for a code example.

/Goran
 
For Paradox tables we created something like this:

// tables in mainreport
for cnt := 0 to (Tables.Count - 1) do
begin
Crpe1.Tables[cnt].Name := NAME + '.db';
Crpe1.Tables[cnt].Path := LOCATION;
end;

// And tables in subreports
for cnt := 0 to (Crpe1.Subreports.Count - 1) do
begin
for i := 0 to (Crpe1.Subreports[cnt].Tables.Count - 1) do
begin
Crpe1.Subreports[cnt].Tables.Name := NAME + '.db';
Crpe1.Subreports[cnt].Tables.Path := LOCATION;
end;
end;

For Oracle just setting Name and Path might not be enough. Just run in debugmode and check the properties of Tables with evaluate for the correct settings.

Examples are for the latest VCL.

Gert

.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.
Crystal Reports & Delphi: New: VBScript UFL and barcodefonts
.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.~`~.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top