来自数据库的数据行不会显示在rdlc报告中

时间:2013-04-18 12:17:59

标签: asp.net dataset rdlc

这是我的代码`

  protected void btnCreateBill_Click(object sender, EventArgs e)
{
    DisplayReport();

}
private DataTable TotalInfoData()
{
    try
    {
        // Open Sql Connection  
        SqlConnection SqlCon = new SqlConnection(@"Data Source=PRATIKPC;Initial Catalog=dbbilling2.0;Integrated Security=True");
        SqlCon.Open();

        // Create a Command  
        SqlCommand SqlComm = new SqlCommand();
        SqlComm.Connection = SqlCon;
        SqlComm.CommandType = CommandType.Text;
        SqlComm.CommandText = "select * from tblTotalFee where Class='" + ClassDropDownList.SelectedItem.Value + "'and StudentID='" + StudentNameDropDownList.SelectedItem.Value+"'";

        // Create instance of Northwind DataSetXSD  
        DataSet1.tblTotalFeeDataTable TotalInfoData = new DataSet1.tblTotalFeeDataTable();

        // Set a Data Commands  
        SqlDataAdapter SqlDa = new SqlDataAdapter(SqlComm);
        SqlDa.Fill(TotalInfoData); // Fill Data in NorthwindDataSet Object.  

        return TotalInfoData;

    }

    catch (Exception ex)
    {
        throw new Exception(ex.Message);
    }
}
private void DisplayReport()
{
    try
    {
        // Clear the Data Source   
        ReportingForPrintingReportViewer.LocalReport.DataSources.Clear();

        // Set a DataSource to the report  

        // First Parameter - Report DataSet Name  
        // Second Parameter - DataSource Object i.e DataTable  
        ReportingForPrintingReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", TotalInfoData()));

        // OR Set Report Path  
        ReportingForPrintingReportViewer.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/Report.rdlc");

        // Refresh and Display Report  
        ReportingForPrintingReportViewer.LocalReport.Refresh();
    }
    catch (Exception ex)
    {
        throw new Exception(ex.Message);
    }
}  

为什么报告中没有任何输出?我的数据库中有行但尚未返回。手术后我的报告看起来像这样。为什么不显示行? enter image description here

这是我的数据集enter image description here

1 个答案:

答案 0 :(得分:0)

尝试在数据集名称前添加架构名称。喜欢 - SchemaName_DataSet1

ReportingForPrintingReportViewer.LocalReport.DataSources.Add(new ReportDataSource("SchemaName_DataSet1", TotalInfoData()));