We’ve tried a lot of different ways to resolve this issue, but are getting every time the different result.
Probably someone deal with that issue before and know how to correctly resolve it.
We’re using Crystal Reports Runtime Components X+ (X, XI, XI R2) – all of them has this issue.
We need client application to connect to multiple data sources – user chooses report, chooses data source and we show the report for specified data source.
The data sources are tables or stored procedures stored in different databases on different servers.
For sure, every data source for a single report has the same structure, but that doesn’t matter.
The issue is: when the name of the database on one server is the same as the name of database on second server, the connection caching occurs.
How we can check that:
1. We’re running report for Server1:<DBN> - report shows data from Server1.
2. We’re opening second report for Server2:<DBN> - report shows data from Server1.
3. We’re closing application and run 1-2 in opposite order, now both reports show data from Server2.
We’ve tried different approaches – below is a code sample that opens the report for specific connection.
Juts to be sure that no one will ask – “Are you sure you’re passing the correct connection info etc.”. Yes! We are sure because we’re trying to fix this issue for a long time and tried a lot of different approaches and still cannot find the right solution.
The code looks like below. This is VB6 code, but also the same situation was tried on VC++ 6.0
We’re not looking into CR.NET solution for now.
=================================================
Sub DisplayReport(Server as String, DB as String, UID as String, PWD as String, viewer as Object)
Dim app As New CRAXDRT.Application
Dim report As CRAXDRT.report
Dim database As CRAXDRT.database
Dim table As CRAXDRT.DatabaseTable
Dim par As CRAXDRT.ParameterFieldDefinition
Set report = app.OpenReport("D:\TestReport_X.rpt")
report.database.LogOnServer "pdssql.dll", Server, DB, UID, PWD
Set table = report.database.Tables(1)
table.SetLogOnInfo Server, DB, UID, PWD
table.Location = table.Name
report.database.Verify
viewer.ReportSource = report
viewer.ViewReport
end sub
=================================================
The result of above code is the following:
1. If we will pass the same viewer and will use different Server – the report will be displayed correctly
2. If we will pass different viewers and will use different Server – the reports will contain same data
The result of above code also depends from the version of Crystal Reports the report was designed in:
1. For Report designed in 8.5 – passing of the same viewer with same connection info second time will refresh report
2. For Report designed in X, XI, XI R2 – no refresh
Also, a slight modification of the above code helps for reports designed in XI to work properly, but not for reports designed in X and 8.5:
1. Before calling LogonServer, make the following: DB = DB & “;” & Int(rnd()*32767)
That makes report designed in XI to display properly in different viewers, but doesn’t have any impact to X and no any impact to 8.5
We’re really looking for any help in this question