2014-03-24 1 views
0

단추에 대한 클릭 이벤트를 사용하여 보고서 뷰어를 통해 보고서를 생성하려고합니다. 그것의 일 벌금. 하지만 데이터베이스 보고서 뷰어에서 내 데이터를 업데이트하면 이전 보고서 만 표시됩니다. 내가 새로 고침 보고서를 사용하려고 시도 too.its 작동하지 않습니다. 데이터 세트에 테이블 어댑터를 사용하여 데이터를 채 웁니다. this.reportViewer1.Reset();보고서 뷰어를 Windows에서 새로 고침 후 보고서를 업데이트하지 않습니다

  Microsoft.Reporting.WinForms.ReportDataSource reportDataSource2 = new Microsoft.Reporting.WinForms.ReportDataSource(); 
      reportDataSource2.Name = "LedgerBy_partyID"; 

      reportDataSource2.Value = this.Ledger_by_Party_IDBindingSource; 


      // this.ReportDataset.Ledger_by_Party_ID.Reset(); 


      this.Ledger_by_Party_IDTableAdapter.Fill(this.ReportDataset.Ledger_by_Party_ID, selected_PartyID); 

      this.reportViewer1.LocalReport.ReportEmbeddedResource = "proj.userReport.Ledger_ByPartyID.rdlc"; 
      this.reportViewer1.LocalReport.DataSources.Clear(); 
      this.reportViewer1.LocalReport.DataSources.Add(reportDataSource2); 
      this.reportViewer1.LocalReport.Refresh(); 
      this.reportViewer1.RefreshReport(); 
+0

보고서 컨트롤은 UpdatePanel에서 호스팅됩니까? – StingyJack

+0

아니오 windows 폼에 사용 중입니다. – user1310554

답변

2

방금 ​​같은 문제가 해결되었습니다. 나는 인터넷에서 며칠을 찾고 있었지만 좋은 대답을 찾을 수 없었다. 그래서 내 글이 누군가가 같은 문제를 극복하는 데 도움이되기를 바랍니다.

당신이해야 할 일은 - 수동으로 연결을 정의하고 데이터 집합을 채우고 소스를 reportviewer에 바인딩하기 만하면됩니다. 여기 내 프로젝트 예제가 있습니다 :

using Microsoft.Reporting.WinForms; 
    private void ReportForm_Load(object sender, EventArgs e) 
    { 
     SqlConnection conn = new SqlConnection(); 
     conn.ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\GD Robotics\VisualProjects\GDPolin\GDPolin\PolinaDB.mdf;Integrated Security=True;Connect Timeout=30"; 
     conn.Open(); 
     SqlDataAdapter reportDBTableAdapter = new SqlDataAdapter("SELECT * FROM [ReportDB]", conn); 
     DataTable polinaDBDataSet = new DataTable(); 
     reportDBTableAdapter.Fill(polinaDBDataSet); 
     conn.Close(); 

     this.reportViewer1.Reset(); 
     this.reportViewer1.LocalReport.DataSources.Clear(); 
     this.reportViewer1.LocalReport.ReportPath = @"D:\GD Robotics\VisualProjects\GDPolin\GDPolin\Report1.rdlc"; 
     ReportDataSource rds = new ReportDataSource("DataSet1", polinaDBDataSet);//"DataSet1" is the name of your dataset. Go to .rdlc form>VIEW>Report Data>"Right click on dataset">Dataset Properties 
     this.reportViewer1.LocalReport.DataSources.Add(rds); 
     this.reportViewer1.RefreshReport(); 
    } 
+0

보고서 뷰어를 재설정 할 필요는 없지만이 기능은 저에게 효과적이었습니다. 새로운 데이터 소스를 추가하기 전에 데이터 소스를 지울 필요가있었습니다. – scuba88