Search code examples
c#mysqlcrystal-reports

i cannot view my crystal report in my simple web page


what seem to be the problem with my code? i cannot view it in my browser. i searched google and so but cannot find the answer. it is been 2 days already that i am looking for solutions. can anyone help thanks.

public partial class WebForm1 : System.Web.UI.Page
{
    string connectionString = "server=" + 
           ConfigurationManager.AppSettings["Server"] + ";uid=" + 
           ConfigurationManager.AppSettings["User ID"] + ";pwd=" + 
           ConfigurationManager.AppSettings["Password"] + ";database=" + 
           ConfigurationManager.AppSettings["Database Name"] + 
           ";Command Timeout=28800;";    

    protected void Page_Load(object sender, EventArgs e)
    {
        EmpReport crystalReport = new EmpReport();
        dsEmp ds = GetData();
        crystalReport.SetDataSource(ds);
        this.CrystalReportViewer1.ReportSource = crystalReport;
        this.CrystalReportViewer1.RefreshReport();
    }

    private dsEmp GetData()
    {
        string query = "SELECT * FROM emp_table";
        MySqlConnection con = new MySqlConnection(connectionString);
        MySqlCommand cmd = new MySqlCommand(query);
        MySqlDataAdapter da = new MySqlDataAdapter();
        cmd.Connection = con;
        da.SelectCommand = cmd;
        dsEmp ds = new dsEmp();
        da.Fill(ds, "DataTable1");
        return ds;
    }
}

Solution

  • I was able to display the Crystal Report by putting the 4_0_30319 folder found in the C://inetpub/wwwroot/aspnet_client/system_web into the root folder of my project. Also make it sure you got correct configurations in your project file (Web.config).