My program is modified from VB.NET. Now I struck with Crystal Report that Crystal Report Viewer didn't show Report Document.
Printing code is composed of two forms. One assign parameters and objects need. Other is Crystal Report Viewer form, CrystalReportForm. Last one run report by parameter from the first.
When run this code that it didn't found any error but the problem is no report show on Crystal Report Viewer on second form. It just blank Crystal Report Viewer. There arm't any message response.
Here is my code.
// report caller form.
privatevoidPrint()
{
CrystalReportForm rptForm =newCrystalReportForm();
string[] strtbl;
strtbl =newstring[1];
string[] strqry;
strqry =newstring[1];
// prepare var
string myqry;
string myrpt;
// Pass The Table That you used in the crystal Report
strtbl[0]="r_receipts";
// Pass the Query
myqry ="SELECT * FROM r_receipts";
myrpt ="rptReceipts.rpt";
strqry[0]= myqry;
//Pass For Mdi True
rptForm.MdiParent=this.ParentForm;
rptForm.ViewReport(myrpt, strtbl, strqry,"");
//Parameter Value It is Optional
rptForm.Show();
}
// Crytal Report Viewer form.
publicvoidViewReport(stringReportName,string[]TableName,string[]QueryString,stringParameter="")
{
//Me.MdiParent = mainpage;
if(TableName.Length !=QueryString.Length )
{
MessageBox.Show("Passed Variable Are Not Correct","Message",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt =newCrystalDecisions.CrystalReports.Engine.ReportDocument();
CrystalDecisions.Windows.Forms.CrystalReportViewer crv =newCrystalDecisions.Windows.Forms.CrystalReportViewer();
crv.ActiveViewIndex=0;
crv.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
crv.ToolPanelView=CrystalDecisions.Windows.Forms.ToolPanelViewType.None;
crv.Dock=System.Windows.Forms.DockStyle.Fill;
crv.Location=newSystem.Drawing.Point(0,0);
crv.Name="CrystalReportViewer";
MySqlDataAdapter at =newMySqlDataAdapter();
DataSet ds =newDataSet();
for(int i =0; i <TableName.Length; i++)
{
at =GetDataAdeptor(QueryString[i]);
at.Fill(ds,TableName[i]);
}
string rptPath ="";
rptPath =Application.StartupPath+"\\"+ReportName;
rpt.Load(rptPath);
rpt.SetDataSource(ds);
if(Parameter!="")
rpt.SetParameterValue(0,Parameter);
crv.ReportSource= rpt;
crv.Refresh();
//CrystalReportViewer.DataBind();
//Me.Panel1.Controls.Add(CrystalReportViewer);
Panel panel1 =newPanel();
panel1.Controls.Add(crv);
}