Hello,
this is my code for printing a Crystal Report.
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[
^]