We help IT Professionals succeed at work.
Get Started

Crystal Reports Datasource Question

Last Modified: 2012-05-11
I have some old Crystal 10 reports I am trying to display in VS2010.  They work fine, until I need to run them on a SQL Server/Database different than the one on which they are created.  I have seen all the code and am using something like shown below.  It appears that the code is not actually making any changes although NO exception is raised.  For example if i trace through the code on my development machine aTable.location will be "Customer" and when I run it, it will change to "MyDatabase.dbo.Customer".  But if the original location is a different Server and or database, the aTable location remains "Customer" and when the viewer attempts to display the report, I get a viewer error stating the connection, server, database, user, and password are empty.  I am using integrated security so I shouldn't need user or password.  Any help appreciated.

Dim crDatabase As Database = crReport.Database
Dim crTables As Tables = crDatabase.Tables
Dim crConnectionInfo As ConnectionInfo = ChangeConnection()
Dim crTableLogOnInfo As New TableLogOnInfo
Dim strLocation As String

For Each aTable In crTables
   crTableLogOnInfo = aTable.LogOnInfo
   crTableLogOnInfo.ConnectionInfo.ServerName = crConnectionInfo.ServerName
   crTableLogOnInfo.ConnectionInfo.DatabaseName = crConnectionInfo.DatabaseName
   strLocation = String.Format("{0}.dbo.{1}", crConnectionInfo.DatabaseName, aTable.Location.Substring(aTable.Location.LastIndexOf(".") + 1))
     aTable.Location = strLocation
   Catch ex As Exception
     'exception code here
   End Try

Private Shared Function ChangeConnection() As ConnectionInfo
Dim objconnectioninfo As ConnectionInfo = New ConnectionInfo
objconnectioninfo.IntegratedSecurity = True
objconnectioninfo.ServerName = "MyServer"
objconnectioninfo.DatabaseName = "MyDatabase"
Return objconnectioninfo

Open in new window

Watch Question
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE