Mahesh Gore

Mahesh Gore

  • NA
  • 9
  • 6.5k

crystal report is not loading

Jul 5 2015 5:14 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using CrystalDecisions.CrystalReports.Engine;

namespace LIC
{
public partial class FormDisplayReport : Form
{
public OleDbConnection connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + ((object)Application.StartupPath).ToString() + "\\Database\\LIC.accdb';Persist Security Info=False;");
public OleDbCommand command;
public OleDbDataAdapter dap;


public string name = "";
public FormDisplayReport()
{
InitializeComponent();
}

private void FormDisplayReport_Load(object sender, EventArgs e)
{
try
{
connection.Open();
DataTable dataTable = this.GetReportData();

CrystalReport2 cust = new CrystalReport2();
//cust.Load(@"CrystalReport1.rpt");

cust.SetDataSource(dataTable);
crystalReportViewer1.ReportSource = cust;
crystalReportViewer1.RefreshReport();
}
catch (Exception ex)
{


}
}


private DataTable GetReportData()
{
try
{
string str = "select * from FORM_IA where Namet ='" + name + "'";

command = new OleDbCommand(str, connection);
dap = new OleDbDataAdapter(command);
DataSet dsRecords = new DataSet();
dap.Fill(dsRecords, "DataTable1");
return dsRecords.Tables["DataTable1"];
}
catch (Exception ex)
{
MessageBox.Show("Erro: " + ex.Message, "Invalid Selection", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
}
}



this is my code ,,,,but crystal report is not loading,,means it shows nothing ..only blank report viewer

Answers (1)