on 01-14-2010 1:36 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.