2013-04-18 192 views
0

这是我code`数据行的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

+0

有什么异常吗? – TechDo

+0

@techdo不,没有例外 –

回答

0

尝试数据集名称前添加架构名称。像 - SchemaName_DataSet1

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

如何获取数据集的模式名称? –