I use following code to populate data in crystal report viewer, when i design report in crystal report, the data is show when i preview, but when use crystal report viewer using following c# code, the data can't show and no any error fetch, this problum is occur only few table, other table report run properly, plz help, i can't understand what can i do.
class RptView
{
private ReportDocument rptDoc;
private ParameterField Parameter;
private ParameterFields Parameters;
private ParameterDiscreteValue ParaValue;
private Connection cnn;
public void ViewReport(CrystalReportViewer CRViewer, string rptName, Forms.ReportView frm, string ParName, Object ParValue)
{
try
{
cnn = new Connection();
cnn.ConnectionString();
rptDoc = new ReportDocument();
rptDoc.Load(Application.StartupPath + "\\Reports\\" + rptName);
Parameter = new ParameterField();
Parameter.Name = ParName;
ParaValue = new ParameterDiscreteValue();
ParaValue.Value = ParValue;
Parameters = new ParameterFields();
Parameter.CurrentValues.Add(ParaValue);
Parameters.Add(Parameter);
rptDoc.SetDataSource(cnn.ConString());
rptDoc.Refresh();
rptDoc.SummaryInfo.ReportAuthor = "";
CRViewer.ParameterFieldInfo = Parameters;
CRViewer.ReportSource = rptDoc;
frm.ShowDialog();
}
catch(Exception e1)
{
MsgBox.MyMessageBox.ShowBox(e1.Message);
}
}
}
}
Call the report as follows
private void itemStockToolStripMenuItem_Click(object sender, EventArgs e)
{
ReportView frm = new ReportView();
RptView rptV = new RptView();
rptV.ViewReport(frm.CRV, "ItemStock.rpt", frm);
}