Skip to Content
author's profile photo Former Member
Former Member

Crystal Runtime - setting the ConnectBufferString properly

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 12, 2010 at 09:25 PM

    Post your SDK questions to the Legacy SDK forum

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.