I had Web application built using VS 2005 which had a crystal report. When I moved the Website from production to dev environment, crystal report stopped working stating that “Procedure or Function expects parameter which was not supplied”. All the parameters were supplied correctly but I was still getting the same error. I checked the code of production site as well as good working copy of another (but same) dev environment. Everything looked same and was working fine. After spending much time, I found one line solution.
Following is my old code that was responsible for updating logon information of each tables used in crystal report
For Each t As CrystalDecisions.CrystalReports.Engine.Table In source.ReportDocument.Database.Tables
crTableLoginInfo = t.LogOnInfo
crTableLoginInfo.ConnectionInfo = c
t.ApplyLogOnInfo(crTableLoginInfo)
Next
I change the above code to include one line and it worked
For Each t As CrystalDecisions.CrystalReports.Engine.Table In source.ReportDocument.Database.Tables
crTableLoginInfo = t.LogOnInfo
crTableLoginInfo.ConnectionInfo = c
t.ApplyLogOnInfo(crTableLoginInfo)
t.Location = con.InitialCatalog + ".dbo." + t.Name ' con is an object of type SqlConnectionStringBuilder. This object is created from Web.config connectionstring. If you have schema different than dbo, you should use that.
Next
The problem occurred because when I moved the Website from production to dev environment, I changed the database name. Apparently, even though Crystal Report could log into the database, somehow did not find the procedure. Now using the above code, it works fine.
Leave a Reply