2013-12-10 2 views
0

Visual Studio 2010과 Crystal Reports 13.0을 사용합니다.Crystal Report 매개 변수 지우기

보고서의 경우 사용자가 값을 입력하라는 메시지가 표시됩니다. 그런 다음 문제없이 보고서가 생성됩니다.

사용자가 report.aspx 페이지를 떠나 다른 보고서를 다시 실행하면 프롬프트가 나타나지 않고 마지막 보고서 실행이 사용자의 원래 값과 함께 계속 유지됩니다. 솔루션을 주변 검색

, 발견 된 두 작동하지 않았다 :

//After the report loads 
CrystalReportSource1.ReportDocument.ParameterFields.Clear(); 

오류 : 당신은 추가 할 수 없습니다

, 제거하거나이 방법을 사용하여 매개 변수 필드를 수정합니다. 보고서를 직접 수정하십시오.

이 바로 크리스탈 리포트 의 몸을 클릭 고토 :

직접 보고서를 수정

디자인 -> 기본 설정 ... ->

보고 확인 확인란을

보고서를로드 할 때 저장된 데이터 무시.

이것은 작동하지 않았습니다. 이전 보고서가 채워집니다.

이제이 문제를 해결하는 방법에 대해 약간의 통찰력을 요구합니다.

항상 그렇듯이 모든 의견을 환영합니다.

감사

편집 : 여기

보고서 페이지 뒤에있는 코드입니다. 많은 보고서에서이 페이지를 사용합니다 ....

  CrystalReportSource1.Report.FileName = "reports\\" + fileName + ".rpt"; 

      //CrystalReportSource1.Report.Parameters.Clear(); 
      //CrystalReportSource1.Report = null; 
      //CrystalReportSource1.Report.Refresh(); 

      if (!string.IsNullOrEmpty(Request.QueryString["item"])) 
      { 
       String Item = Request.QueryString["item"]; 
       CrystalDecisions.Web.Parameter temp = new CrystalDecisions.Web.Parameter(); 
       temp.Name = "Item"; 
       temp.DefaultValue = Item; 
       CrystalReportSource1.Report.Parameters.Add(temp); 
      } 

      SqlConnectionStringBuilder settings = new SqlConnectionStringBuilder(MyConnectionString); 

      _crReportDocument = CrystalReportSource1.ReportDocument; 
      _crConnectionInfo.ServerName = settings.DataSource; 
      _crConnectionInfo.DatabaseName = settings.InitialCatalog; 
      _crConnectionInfo.UserID = settings.UserID; 
      _crConnectionInfo.Password = settings.Password; 

      //Get the table information from the report 
      _crDatabase = _crReportDocument.Database; 
      _crTables = _crDatabase.Tables; 

      //Loop through all tables in the report and apply the 
      //connection information for each table. 
      for (int i = 0; i < _crTables.Count; i++) 
      { 
       _crTable = _crTables[i]; 
       _crTableLogOnInfo = _crTable.LogOnInfo; 
       _crTableLogOnInfo.ConnectionInfo = _crConnectionInfo; 
       _crTable.ApplyLogOnInfo(_crTableLogOnInfo); 
      } 

답변

0

Page_Unload 이벤트에서 사용해 볼 수 있습니다.

Report.Close(); 
Report.Dispose(); 

페이지가 언로드되면 보고서를 삭제해야하며 사용자가 페이지로 돌아올 때 새로 시작해야합니다. 이 게시물에 좋은 예가 있습니다 here.

+0

죄송 합니다만 Page_Unload 이벤트는 모든 것이로드 된 후에 시작됩니다. 따라서보고하기 전에 보고서를 닫거나 처분 할 것입니다. –

+0

질문에 추가 한 코드를 보았습니다. 왜 2 번에서 4 번 줄을 주석 처리 했습니까? 그러면 처리해야합니다. Page_Load에서 모든 것을 지우고 보고서를로드하십시오. –

+0

내가 주석 처리 한 행은 작동하지 않았지만 나는 거기에 두었으므로 다시 시도하지 않습니다. –

0

해결책을 찾았습니다 !!!! --------하지

은 위에서 내 질문에 모든 코드 전에이 줄을 추가합니다 .......

CrystalReportViewer1.ParameterFieldInfo.Clear(); 

그런 다음 등 파일 이름을로드하고

+0

글쎄, 나는 그것을 가져 간다. 위의 새로운 행이 테스트 된 후에 보고서 인쇄가 금지됩니다. 아주 이상한. 나는 해결책을 찾을 것이다 .... –