2012-08-08 3 views
0

Windows 프로젝트 용 Crystal Reports를 작성했습니다. Visual Studio에서 실행할 때 제대로 작동합니다. (저는 VS 2010을 사용하고 있습니다). 하지만 설치 프로젝트를 만들고 클라이언트 PC에 소프트웨어를 설치 한 후에는 작동하지 않습니다.프로젝트 설정을 작성한 후 Crystal 보고서가 작동하지 않습니다.

http://tistus.srilanka-erickson.com/errors.html

표시 다음은 내가 결정 보고서를로드하는 데 사용한 버튼 클릭 이벤트 코드입니다 : 첫 번째 절은 보고서에 사용자 입력을 등록하는 데 사용 된 시도, 그 사이에 두 번째 나는 다음과 같은 오류를 얻을 수 try 절은 보고서에 대한 데이터베이스 연결을 수동으로 만드는 데 사용되었습니다. 세 번째 try 절은 보고서를로드하는 데 사용되었습니다.

private void buttonGenerateSecExportRpt_Click(object sender, EventArgs e) 
    { 
     CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); 
     if (comboBoxSecPlateType.Text != "" && comboBoxSecExPlateBrand.Text != "") 
     { 
      try 
      { 
       dtFrom.Format = DateTimePickerFormat.Custom; 
       string periodfrom = dtFrom.Value.ToString("yyyy/MM/dd"); 
       dtTo.Format = DateTimePickerFormat.Custom; 
       string periodto = dtTo.Value.ToString("yyyy/MM/dd"); 

       //cryRpt.VerifyDatabase(); 
       string fullPath = "..\\..\\SecondaryPlateExportReport.rpt"; 
       cryRpt.Load(fullPath); 
       cryRpt.SetParameterValue("dateFromChecked", dtFrom.Checked); 
       cryRpt.SetParameterValue("dateToChecked", dtTo.Checked); 
       cryRpt.SetParameterValue("dtPeriodFrom", periodfrom); 
       cryRpt.SetParameterValue("dtPeriodTo", periodto); 
       cryRpt.SetParameterValue("PlateType", comboBoxSecPlateType.Text.Trim()); 
       cryRpt.SetParameterValue("PlateBrand", comboBoxSecExPlateBrand.Text.Trim()); 

      } 
      catch (Exception ex) 
      { 
       MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
      } 
      try 
      { 
       DbConnectionInfo.SetConnectionString(ConfigurationManager.ConnectionStrings["con"].ToString()); 
       TableLogOnInfo logOnInfo; 
       ConnectionInfo connectionInfo; 
       foreach (Table table in cryRpt.Database.Tables) 
       { 
        logOnInfo = table.LogOnInfo; 
        connectionInfo = logOnInfo.ConnectionInfo; 
        // Set the Connection parameters. 
        connectionInfo.DatabaseName = DbConnectionInfo.InitialCatalog; 
        connectionInfo.ServerName = DbConnectionInfo.ServerName; 
        if (!DbConnectionInfo.UseIntegratedSecurity) 
        { 
         connectionInfo.Password = DbConnectionInfo.Password; 
         connectionInfo.UserID = DbConnectionInfo.UserName; 
        } 
        else 
        { 
         connectionInfo.IntegratedSecurity = true; 
        } 
        table.ApplyLogOnInfo(logOnInfo); 
       } 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
      } 
      try 
      { 
       crystalReportViewerSecEx.ReportSource = cryRpt; 
       crystalReportViewerSecEx.Refresh(); 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
      } 
     } 
     else 
     { 
      MessageBox.Show("Please select both Plate Type and the Brand to Generate the Report!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
     } 
    } 

클라이언트 컴퓨터에 소프트웨어를 배포 한 후에 수정 보고서를 작성하려고합니다. 어떤 제안이라도 대단히 감사하겠습니다!

답변

0

Shehan,

모든 .NET 프로젝트에서 하드 코드 된 경로를 사용하지 않는 것이 가장 좋습니다. Server.MapPath 변수를 사용하고 문자열을 동적으로 작성하는 것이 가장 좋습니다.

예를 들어 System.IO를 프로젝트에 추가하십시오. 그런 다음 Path.Combine 메서드를 사용하여 문자열을 작성할 수 있습니다. 이 변화의 두려움없이 여러 번 호출 할 수 있도록

string mappath = HttpContext.Current.Server.MapPath("~/"); 
    Path.Combine(mappath, "Report Folder Path", "FileName.rpt"); 

당신은 정적 문자열로 "보고서 폴더 경로"를 배치 할 수 있습니다.

통해 UR RPT 및 .cs 복사 : 유 생성 설정이

같은 UR 크리스탈 보고서 경로를 넣어

2
crystalReport.Load(@"C:\WINDOWS\Temp\samridhi.rpt"); 

을 "\ WINDOWS \ 온도C"이동 파일을 "C : \ WINDOWS \ Temp"mycomputer가 실행하지 않음으로 이동하십시오.

하지 설정을위한210

는 여기 프로젝트 응용 프로그램에서 Crystal 보고서 경로를 확인하는 경로가

crystalReport.Load(System.Windows.Forms.Application.StartupPath + "\\samridhi.rpt"); 
입니다

입니다

관련 문제