Click here to Skip to main content
15,884,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900