cancel
Showing results for 
Search instead for 
Did you mean: 

Report Document not show on Crystal Report Viewer in C#

Former Member
0 Kudos

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.
private void Print()
  
{
  
CrystalReportForm rptForm = new CrystalReportForm();
  
string[] strtbl;
  strtbl
= new string[1];
  
string[] strqry;
  strqry
= new string[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.
public void ViewReport(string ReportName , string[] TableName, string[] QueryString , string Parameter = "")
  
{
  
//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 = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
  
CrystalDecisions.Windows.Forms.CrystalReportViewer crv  = new CrystalDecisions.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 = new System.Drawing.Point(0, 0);
  crv
.Name = "CrystalReportViewer";

  
MySqlDataAdapter at =new MySqlDataAdapter();
  
DataSet ds = new DataSet();
  
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 = new Panel();
  panel1
.Controls.Add(crv);
  
}

Accepted Solutions (1)

Accepted Solutions (1)

former_member188030
Active Contributor
0 Kudos

What happens when you export the report from viewer, does the exported pdf show any data?

as you are using dataset, this could also be an issue with DS.

Could you print the data from DS to a datagrid and see if the DS actually returns the data.

- Bhushan

Senior Engineer

SAP Active Global Support

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Former Member
0 Kudos

Thank for advise, Bhushan. I do it now.

Former Member
0 Kudos

Hi Bhushan,

Dataset has a problem as you suggest. Thank very much.

Chaiwat

former_member188030
Active Contributor
0 Kudos

Happy to help

Former Member
0 Kudos

Hi Bhushan,


It's not yet fixed. My dataset (ds) can't bine to DataGridView as

DataGridView1.DataSource = ds


But it could do like this

DataGridView1.DataSource = ds.Tables[0];


When I bine to Crystal Report Viewer setdatasource

CrystalReportViewer1.setdatasource = ds.Tables[0];


It still not work, anyway you suggest let me in the right way. I very confuse the thing I fix to bine to DataGridView


Thank,

Chaiwat

former_member188030
Active Contributor
0 Kudos

Try,

CrReportDocument.Setdatasource = ds.Tables[0];

CrystalReportViewer1.ReportSource = CrReportDocument;

See if this helps.

http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/401c4455-a31d-2b10-ae96-fa57af5ae...

Thanks,

Bhushan

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

I already fixed it.

Thanks

Chaiwat