I have a report made with Crystal Reports 2008 that I need to deploy a production system which means that I need to be able to change the database connection at runtime. Th
I just went through this same ordeal.
I set my connections like this (where sDataSource etc... are string with the information)
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
myConnectionInfo.ServerName = sDataSource
myConnectionInfo.DatabaseName = sInitialCatalog
myConnectionInfo.UserID = sUserID
myConnectionInfo.Password = sPassword
Dim myTables As Tables = report.Database.Tables
Dim myTableLogonInfo As TableLogOnInfo = New TableLogOnInfo()
myTableLogonInfo.ConnectionInfo = myConnectionInfo
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
myTable.ApplyLogOnInfo(myTableLogonInfo)
myTable.LogOnInfo.ConnectionInfo.DatabaseName = myTableLogonInfo.ConnectionInfo.DatabaseName
myTable.LogOnInfo.ConnectionInfo.ServerName = myTableLogonInfo.ConnectionInfo.ServerName
myTable.LogOnInfo.ConnectionInfo.UserID = myTableLogonInfo.ConnectionInfo.UserID
myTable.LogOnInfo.ConnectionInfo.Password = myTableLogonInfo.ConnectionInfo.Password
Next