on 07-15-2009 7:45 PM
I'm using Crystal Reports v10 runtime in a Delphi 2007 Win32 application.
The app supports both Oracle and Intersystems Cache.
I don't use a TNSNAMES.ORA file or an ODBC DSN to connect to either database. This is so our clients
IT departments don't have to install these connections on every workstation.
When the app runs reports it sets the database location to the client's database. Doing this in Delphi code works great with Oracle. But I can't get it to work with Cache.
I'm trying to use the ConnectBufferString property but obviously I'm not passing the correct values to this property.
Here's the code. It blows up at .Location := 'DEV.' + ... with this error:
Logon failed. Cannot find DSN in connection string.
Anyone have any experience with this?
procedure TfmTest.TestClick(Sender: TObject);
var
SubReport: IReport;
ReportObject: IReportObject;
Sections: ISections;
Section: ISection;
Report: IReport;
strConn: string;
x,y,z: SmallInt;
begin
Report := CRApp.OpenReport('C:\QMDEV\qes\QES\9.4.0.0\Reports\DivisionSingleLineListing.rpt',crOpenReportByTempCopy);
if Report.HasSavedData then
Report.DiscardSavedData;
Report.Database.ConvertDatabaseDriver('CRDB_ODBC.DLL',True);
strConn := Report.Database.Tables[1].ConnectBufferString;
for x := 1 to Report.Database.Tables.Count do begin
Report.Database.Tables[x].ConnectBufferString := strConn;
Report.Database.Tables.Item[x].Location := 'DEV.' + Report.Database.Tables.Item[x].Location;
end;
Sections := Report.Sections;
for x := 1 to Report.Sections.Count do begin
Section := Sections.Item[x];
for y := 1 to Section.ReportObjects.Count do begin
Application.ProcessMessages;
ReportObject := Section.ReportObjects.Item[y] as IReportObject;
if ReportObject.Kind = crSubReportObject then begin
SubReport := (Section.ReportObjects.Item[y] as SubReportObject).OpenSubReport;
SubReport.Database.ConvertDatabaseDriver('CRDB_ODBC.DLL',True);
for z := 1 to SubReport.Database.Tables.Count do begin
SubReport.Database.Tables[x].ConnectBufferString := strConn;
SubReport.Database.Tables.Item[z].Location := 'DEV.' + SubReport.Database.Tables.Item[z].Location;
end;
end;
end;
end;
end;
Thanks for any help anyone can provide.
Post your SDK questions to the Legacy SDK forum
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.