Click here to Skip to main content
15,789,698 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
This is my code to display data from database using and c#. But i am unable to display any data in the report.please help me in this:

Here is my Code:

SqlConnection myconn;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
    if (PreviousPage != null)
        DropDownList ddl1 = PreviousPage.FindControl("ddlyear") as DropDownList;
        DropDownList ddl2 = PreviousPage.FindControl("ddlsem") as DropDownList;
        DropDownList ddl3 = PreviousPage.FindControl("ddlsubid") as DropDownList;
        DropDownList ddl4 = PreviousPage.FindControl("ddltype") as DropDownList;
        DropDownList ddl5 = PreviousPage.FindControl("ddlmonth") as DropDownList;
        myconn = new SqlConnection(@"Data Source=TIMSCDR\SQLEXPRESS;Initial Catalog=IAP;Integrated Security=True");
        string str4 = "select stuid,present,absent,working from attendance1 where year = '" + ddl1.Text + "' and sem = '" + ddl2.Text + "' and subid = '" + ddl3.Text + "' and type = '" + ddl4.Text + "' and month = '" + ddl5.Text + "'";
        cmd = new SqlCommand(str4, myconn);
        SqlDataAdapter da4 = new SqlDataAdapter(cmd);
        DataSet ds4 = new DataSet();
        da4.Fill(ds4, "DataTable1");
        ReportDocument report = new ReportDocument();
        CrystalReportViewer1.ReportSource = report;

Thanks in Advance.
Updated 9-Jun-11 23:39pm
Sunasara Imdadhusen 10-Jun-11 5:00am    
is there any error?
debo_india 10-Jun-11 5:06am    
no error but no data is being displayed
Prasad CM 10-Jun-11 6:10am    
Check Once whether DropDownList Value is Loading Or Not ?

1 solution

OK Try my suggestions....

  • Verify database in the report
  • Confirm you have data in the dataset or datatable
  • Give the name for Dataset & Datatable same as in the report.
  • If the table name is Table1 in report then your code should be like below.
    DataTable dt = new DataTable("Table1");

    Also the same to dataset.
    If the dataset name is Dataset1 in report then your code should be like below.
    DataSet ds = new DataSet1("Dataset1");

Further reading
Crystal Report Blank / Empty / Not Displaying. No On-Screen Error, But Event Log ‘ConfigurationErrorsException’ Received[^]

Let me know....
Share this answer
Sandeep Mewara 10-Jun-11 11:43am    
My 5!

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

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