Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using visual studio 2010 and crystal report 13.0.18.2192 version, But I have a problem when I try to pass a new parameter field to existing report It won't appear, give an error.. I want to pass The Shop name as the top of the report, I tried it by passing as a textobj in the report but I will print correctly by print preview but when I run it inside the program it prints like as my old crystal report (with out shop name).

What I have tried:

double discountP = 0;
if (txtDis.Text.Length > 0 && txtDis.Text!="0")
    discountP = double.Parse(txtDis.Text);
string path2="";
if ((InvNo.StartsWith("CAS-V") || InvNo.StartsWith("INV-V")) && needVat && discountP == 0)
path2 = Path.Combine(Environment.CurrentDirectory, @".\CrystalReporInvoiceVat.rpt");
else if(discountP>0)
path2 = Path.Combine(Environment.CurrentDirectory, @".\CrystalReporInvoiceVat.rpt");
else
 path2 = Path.Combine(Environment.CurrentDirectory, @".\CrystalReportSalesInv.rpt");
rptDoc.SetDataSource(ds1);
rptDoc.DataSourceConnections.Clear();
rptDoc.SetParameterValue("ShopName", "NEW SINGHE HARDWARE STORES");
//rptDoc.SetParameterValue("ShopAdd", "29 Karalliyadda Theldeniya Tel:081-2050044 081-2050040 077-3777713");
rptDoc.SetParameterValue("CusName", txtName.Text);
rptDoc.SetParameterValue("CusID", txtInvTo.Text);
rptDoc.SetParameterValue("CusAdd1", txtCusDetails1.Text);
Posted
Updated 17-May-18 22:41pm

1 solution

This solution was working for me. just have a try.
 var date = DateTime.Today();
 ReportDocument report = new ReportDocument();
 CrystalReportViewer crystalReportViewer1 = new CrystalReportViewer();

//Attach datasource etc. here
 report.SetParameterValue("@EndDate", date);
 crystalReportViewer1.RefreshReport();         
 
Share this answer
 

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