2 Replies Latest reply: Jan 19, 2010 9:37 AM by greg greg RSS

change databasename, crystal 9, delphi, craxdrt9

greg greg
Currently Being Moderated

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

Actions