I have created some VS 2005 Crystal Reports on my development machine that use a SQL Server DB . I entered the connection info when I made the reports. These run fine on my development machine but the production web server's SQL server 's name is different from the one on my development machine. I need a way to design the report on my development machine then run it on other servers with different SQL Server names.
I have attached code for what I have attempted so far. I put the appsettings in my webconfig at the end of the code snippet. The code is something I downloaded while trying to research this.
When I run it the section that reads the config file does not see anyy application settings so
If (0 < rootWebConfig1.AppSettings
Count) is false . That's one problem.
The other is when it runs it has no effect at all on my development machine - the report seems to get connection info from the report and ignore the attached code . When it runs on the production machine I get an error that it can't find the server. I changed the webconfig on the production server to show the correct value for the SQL Server there in AppSettings but the code doesn't seem to have any effect on the report connection.
SO what I want to do is develop a Crystal Report on my development machne using VS 2005 and have it still work on the production web server using that machine's SQL Server. This must be a really common thing to do for everyone. Can you make my code work or suggest an altogether easier way to approach this?
Partial Class LE100_LE_100MainReport
Public LE100 As New ReportDocument
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Protected Sub ConfigureCrystalReports()
Dim this As String
Dim rootWebConfig1 As System.Configuration.Configuration
rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Nothing)
If (0 < rootWebConfig1.AppSettings.Settings.Count) Then
Dim customSetting As System.Configuration.KeyValueConfigurationElement
customSetting = rootWebConfig1.AppSettings.Settings("LE100DB")
If Not (Nothing = customSetting.Value) Then
this = customSetting.Value
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
myConnectionInfo.ServerName = this
Dim thing As String = ""
Select Case Session("Le100Report")
thing = "le100 zip then strt param.rpt"
thing = "le100 officer zip street.rpt"
thing = "Le100 zip then strt.rpt"
Dim rpt As String
rpt = Server.MapPath(thing)
Me.CrystalReportViewer1.ReportSource = LE100
Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo)
Dim myTableLogOnInfos As TableLogOnInfos = CrystalReportViewer1.LogOnInfo()
For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
myTableLogOnInfo.ConnectionInfo = myConnectionInfo
+++++++++from Webconfig below
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
<add key="LE100DB" value="TOMKOVICLAP3" />