Click here to Skip to main content
15,887,302 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
this is my code for printing a Crystal Report.
C#
protected void Print(object sender, EventArgs e)    
       {    
           ImageButton lnkRowSelection = (ImageButton)sender;    
           ReportDocument cryRpt = new ReportDocument();    
    
           string[] commandArgs = lnkRowSelection.CommandArgument.ToString().Split(new char[] { ',' });    
           string idno = commandArgs[0];    
           string company = commandArgs[1];    
    
           try    
           {    
               if (lnkRowSelection.CommandArgument.ToString() == null)    
                   Response.Redirect("Default.aspx");    
               else    
               {    
                   if (company == "True")    
                       cryRpt.Load(Server.MapPath("~/Reports/rep1.rpt"));    
                   else    
                       cryRpt.Load(Server.MapPath("~/Reports/rep2.rpt"));    
    
                   if (lnkRowSelection.CommandArgument.ToString() != null)    
                   {    
                       cryRpt.SetParameterValue("@idno", idno);    
                       cryRpt.SetParameterValue("Office", agr.getOffice());    
                       cryRpt.PrintToPrinter(2, true, 1, 2);     
                   }    
               }    
           }    
           catch (Exception ex) { appObj.myMessageBox(ex.Message); }    
    
       }  


Rep1 and Rep2 were created using Report Wizard and are binded to a sproc. Idno is a parameter for the sproc and office is a second parameter i added to the report.

The problem is that I get the error "The types of the parameter field and parameter field current values are not compatible" but only when I use the published version. If I run the application through Visual Studio the report is printing just fine.

I'm using Windows Server 2012 R2, IIS 8.5 , Crystal Reports 13, .NET Framework 4.5.2

Any ideas what might be wrong?

Thank you in advance.

What I have tried:

Checked that both parameters are data type String and getting string as input.
Checked that there are no null values as input.
Change .rpt properties to Content
Followed this article instructions but still doesn't work.
Crystal Reports not rendering when webpage is served outside of network[^]
Posted
Updated 13-Nov-16 23:10pm
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900