在水晶报表中显示数据 [英] display data in crystal reports

查看:67
本文介绍了在水晶报表中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
这是我的代码,用于使用asp.net和c#显示数据库中的数据.但是我无法在报表中显示任何数据.请在此方面帮助我:

这是我的代码:

Hi All,
This is my code to display data from database using asp.net 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");
        myconn.Open();
        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();
        report.Load(Server.MapPath("CrystalReport1.rpt"));
        report.SetDataSource(ds4);
        CrystalReportViewer1.ReportSource = report;
        myconn.Close();
    }
}



在此先感谢.



Thanks in Advance.

推荐答案

OK尝试我的建议....


  • 验证报告中的数据库
  • 确认您在数据集中或数据表中有数据
  • 为数据集&数据表与报表中的数据相同.
  • 如果报表中的表名称为Table1,则您的代码应如下所示.
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");


与数据集也相同.
如果报表中的数据集名称为Dataset1,则您的代码应如下所示.


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");



这篇关于在水晶报表中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆