Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Issue with changing connection to DB Post Reply Post New Topic
Author Message
dmazourick
Newbie
Newbie


Joined: 24 Apr 2008
Online Status: Offline
Posts: 2
Quote dmazourick Replybullet Topic: Issue with changing connection to DB
    Posted: 24 Apr 2008 at 6:35am

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

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 24 Apr 2008 at 7:01pm
Wow. This is the most well-written question I've seen posted here. However, I think this is a bug and should be reported to CR tech support. You clearly understand all the details of changing a data source. What makes me think that this is a bug is that the same code exhibits different behavior depending upon the order you run the report in. Thus, the code that sets the server/database is correct and the caching can be proven. Also, have you tried disposing of the report object completely (in .NET you set it to Nothing (null in C#) and force garbage collection). This might help.


Edited by BrianBischof - 24 Apr 2008 at 7:04pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
dmazourick
Newbie
Newbie


Joined: 24 Apr 2008
Online Status: Offline
Posts: 2
Quote dmazourick Replybullet Posted: 25 Apr 2008 at 7:50am
Yes, we've tried to dispose all objects (sure, viewer is not disposed) by:
 
Set table = nothing
Set database = nothing
Set report = nothing
Set app = nothing
 
That doesn't help at all
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 25 Apr 2008 at 12:18pm

Have you tried doing

report.database.LogOffServer "pdssql.dll", Server, DB

prior to disposing of the database and report?
 
-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.048 seconds.