cancel
Showing results for 
Search instead for 
Did you mean: 

change databasename, crystal 9, delphi, craxdrt9

Former Member
0 Kudos

Hi,

My Connection inside my Crystal Reports is pointing to BASE1.

to view and change database name (because I want to read BASE2 data) I write the following code

crReport := crApplication1.OpenReport('c:\temp\test.rpt', crOpenReportByTempCopy);

crReport.DiscardSavedData;

// Log each table instance on at the database.

for i := 1 to crReport.Database.Tables.Count do begin

showmessage('1--->'+ crReport.Database.Tables.Item<i>.ConnectBufferString);

crReport.Database.Tables.Item<i>.ConnectionProperties.Item['data source'].Value := '(local)\ShortcutsPOS';

crReport.Database.Tables.Item<i>.ConnectionProperties.Item['initial catalog'].Value := 'BASE2';

showmessage('2--->'+ crReport.Database.Tables.Item<i>.LogOnDatabaseName);

end;

CRViewer91.ReportSource := crReport;

CRViewer91.ViewReport;

end;

it work but the report displays the data from BASE1

the fist SHOWMESSAGE display :

Provider=SQLOLEDB;;Data Source=(local)\shortcutspos;;Initial Catalog=BASE1;;User ID=;;Password=;;Integrated Security=-1;;Locale Identifier=1036;;Connect Timeout=15;;General Timeout=0;;OLE DB Services=-5;;Current Language=;;Initial File Name=;;Use Encryption for Data=0;;Replication server name connect option=;;Tag with column collation when possible=0

the second one:

Provider=SQLOLEDB;;Data Source=(local)\shortcutspos;;Initial Catalog=BASE2;;User ID=;;Password=;;Integrated Security=-1;;Locale Identifier=1036;;Connect Timeout=15;;General Timeout=0;;OLE DB Services=-5;;Current Language=;;Initial File Name=;;Use Encryption for Data=0;;Replication server name connect option=;;Tag with column collation when possible=0

help !

thx

greg

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Greg,

Search Forums for Delphi, you'll find your answer. Short version is you also need to use the .Location method to update the report, all you are doing is logging onto the new data but not setting location to the new info.

Also be sure to use the DiscardSavedData, it also will stop CR from using the new log on info.

Thank you

Don

Former Member
0 Kudos

thank you for your reply;

In fact, I found this sample code in the forum ....;)

I only fond a property "location" , crReport.Database.Tables.Item<i>.Location but it gives me the name of the table and I can't assign it.

do you have, please, the name of the method ?

thank you again

greg

Answers (0)