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

问题描述

大家好,
这是我的代码,用于使用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.

推荐答案

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



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

08-04 03:26
查看更多