2017-03-13 1 views
1

을 표시하지,하지만 난ASP 닷넷 C# 웹 페이지 RDLC 보고서 나는 C# 및 Asp.net 내가 RDLC 보고서를 사용하는 것을 시도하고 새로운 오전 데이터

<body> 
    <form id="form1" runat="server"> 
    <div> 


     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 

     <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" > 
      <LocalReport ReportPath="Report.rdlc"> 

      </LocalReport> 

     </rsweb:ReportViewer> 

     <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 

     <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 
    </div> 

    </form> 
</body> 




protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!IsPostBack) 
    { 
     string before = Session["before"].ToString(); 
     string after = Session["after"].ToString(); 

     Label1.Text = before.ToString(); 
     Label2.Text = after.ToString(); 

     string src = "Data Source=.; Initial Catalog=mydbtry; Integrated Security=true;"; 
     SqlConnection con = new SqlConnection(src); 
     try 
     { 
      con.Open(); 

      DateTime b = Convert.ToDateTime(before); 
      DateTime a = Convert.ToDateTime(after); 
      string query = "Select * from firstTable where id = 155"; 
      SqlCommand cmd = new SqlCommand(query); 
      DataSet ds; 
      using (con) 
      { 
       using (SqlDataAdapter da = new SqlDataAdapter()) 
       { 
        cmd.Connection = con; 
        da.SelectCommand = cmd; 
        ds = new DataSet(); 
        da.Fill(ds); 

       } 
      } 

      ReportViewer1.ProcessingMode = ProcessingMode.Local; 
      ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc"); 
      ReportDataSource rds = new ReportDataSource("DataSet1", ds.Tables[0]); 
      ReportViewer1.LocalReport.DataSources.Clear(); 
      ReportViewer1.LocalReport.DataSources.Add(rds); 
      ReportViewer1.LocalReport.Refresh();     
     } 


     catch (Exception ex) 
     { 


     } 


    } 
보고서에 데이터를 인쇄 할 수 없습니다입니다

지금 직면하고있는 문제는 내 테이블이 비어 있고 데이터가 채워지지 않는다는 것입니다. SQL Server 2012를 사용하고 있으며 이미 잘 작동하는 연결을 확인했습니다. 실행 후

enter image description here

데이터 세트

enter image description here

어떤 도움은 매우 극명하게 될 것이다

enter image description here

Report.RDLC.

답변

1

ObjectDataSource 컨트롤을 통해 보고서를 채우십시오. 자동으로 작동하므로 코드를 입력 할 필요가 없습니다.

+0

저는 이미이 문제를 직접 해결했습니다. 내 DataSet retieved 올바른 테이블 ... 어쨌든 고마워요. –