Knowledge.ToString()

Crystal Report Error: Procedure or Function expects parameter which was not supplied

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.

Share

Comments

One response to “Crystal Report Error: Procedure or Function expects parameter which was not supplied”

  1. William Chau Avatar
    William Chau

    Hi Vishal,

    Thank you very much for sharing this!

    I spent a couple of days trying to work out this very issue! I had 2 different database instances on the same database server and every time I tried to connect to the second database instance, the Crystal Report would connect to the original database instance configured in the report.

    I tried manually updating the QE_DatabaseName and Initial Catalog DbConnectionAttributes to no avail. After ApplyLogOnInfo was called, the tables would revert to the original database name.

    Prepending the new database instance’s name to the table.Location resolved the issue!

    Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *