安裝和部署項目–水晶報表

來源:互聯網
上載者:User

如果你想在“乾淨”的機器上成功安裝和使用水晶報表,請按照下列步驟:

1)建立“安裝和部署項目”-->“安裝嚮導”
(2)選擇項目類型(這裡選“建立用於windows應用程式的安裝程式”)-->下一步
(3)選擇要包含的檔案:要部署使用 Crystal Reports for Visual Studio .NET 2003 的程式,需要添加合併模組(在方案總管中tree的頂端節點右鍵-->添加).
Crystal_Database_Access2003.msm
Crystal_Database_Access2003_enu.msm
Crystal_Managed2003.msm
Crystal_regwiz2003.msm
VC_User_CRT71_RTL_X86_---.msm
VC_User_STL71_RTL_X86_---.msm
你可以 'C:/Program Files/Common Files/Merge Modules' 檔案夾下找到替換的合併模組。
(4)開啟解決方案-->右鍵點擊Crystal_regwiz2003.msm 的屬性,在“MergeMouduleProperties”裡的“License Key”填入:***************************(這個是你產生Crystal Report是用到的註冊號的密碼!)
(5)產生解決方案
如果沒有第四步,會產生在執行列印報表時提示keycodev2.dll或者無效密碼的錯誤。
以上的步驟,如果你的“乾淨”的機器上裝有水晶報表,那麼到這裡完全就可以了。
如果你不希望在“乾淨”的機器上裝水晶報表,繼續以下的步驟:
在“添加項目輸出組”中,選擇“主輸出”,然後單擊“確定”。
將自動添加所有依賴項,如 dotnetfxredist_x86_enu.msm和dotnetcrystalreports.msm。
  2.需要將dotnetcrystalreports.msm排除在項目之外,在方案總管中右擊這個模組的右鍵,選擇“排除”。
  3.在方案總管中,右擊安裝項目,指向“添加”,然後單擊“合併模組”。
  4.在“添加模組”對話方塊中,選擇下列要添加到安裝項目的合併模組,然後單擊“開啟”:
reportengine.msm,
crnetruntime.msm
license.msm
mapping.msm (可選,當在報表中使用了geographic maps時)
     5.在方案總管中,右擊 license.msm 檔案,然後選擇“屬性”。
  6.在“屬性”視窗中,展開 MergeModuleProperties,然後在“許可證密鑰”屬性框中輸入一個有效許可證密鑰。
    注意 :  每當部署 Crystal Reports 應用程式時,必須提供許可證密鑰。
  7.從“產生”菜單中,選擇“產生解決方案”以產生應用程式
  如果以上步驟沒有的化,會提示“load crpe32.dll failed”的錯誤。
  用到的模組:  http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9netmergemodules_chs.zip.asp
http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9netredist_chs.zip.asp
http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9rdcmergemodules_chs.zip.asp
  如果你的機器上裝的是windows 98,不繼續以下的步驟會產生"Load Report Failed" (CRQE.dll)的錯誤。
報表在部分Win98的用戶端可以載入,在部分Win98的用戶端載入報表時卻提示"Load Report Failed"是因為水晶報表運行時所需的 CRQE.dll 在用戶端的系統註冊不正確,而原因又是ATL.dll 的版本不對(Windows 98/ME下的正確版本號碼應為3.0.8449)。
解決辦法有兩條:
1.在用戶端安裝 IE6.0,難怪有的用戶端運行正常。
2.將 ATL.msm 模組添加到安裝工程,ATL.msm 是 Visual Studio installer 1.1 的一部分,可以去微軟的網站http://msdn.microsoft.com/vstudio/downloads/tools/vsi11/download.aspx下載, 添加辦法同上。
至此,可以說打包基本完成。不過還要注意:
如果你用的是水晶報表的推模式,一般不用設定登陸資訊,但是要這樣寫:obj.SetDataSource(this.ds.Tables["tablename"]);如果你寫成了obj.SetDataSource(this.ds)就會有登陸框的。
如果你用的是水晶報表的拉模式,你就一定要寫上登陸資訊:
crReportDocument = new OracleReport();
   //Set the crConnectionInfo with the current values stored in the report
   crConnectionInfo = crReportDocument.Database.Tables[0].LogOnInfo.ConnectionInfo;
   /* Populate the ConnectionInfo Objects Properties with the appropriate values for
   the ServerName, User ID, Password and DatabaseName. However, since Oracle
   works on Schemas, Crystal Reports does not recognize or store a DatabaseName.
   Therefore, the DatabaseName property must be set to a BLANK string. */
   crConnectionInfo.DatabaseName = "";
   crConnectionInfo.ServerName = "Your Server Name";
   crConnectionInfo.UserID = "Your User ID";
   crConnectionInfo.Password = "Your Password";
   //Set the CrDatabase Object to the Report's Database
   crDatabase = crReportDocument.Database;
   //Set the CrTables object to the Tables collection of the Report's dDtabase
   crTables = crDatabase.Tables;
   //Loop through each Table object in the Tables collection and apply the logon info
   //specified ealier. Note this sample only has one table so the loop will only execute once
   foreach (Table crTable in crTables)
   {
    crTableLogOnInfo = crTable.LogOnInfo;
    crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
    crTable.ApplyLogOnInfo (crTableLogOnInfo);

    // if you wish to change the schema name as well, you will need to set Location property as follows:
    // crTable.Location = "<new schema name>." + crTable.Name;
   }
   //Set the ReportSource of the CrystalReportViewer to the strongly typed Report included in the project
   crystalReportViewer1.ReportSource = crReportDocument;
還有一點要注意:
如果你用到了子報表,一定要處理:
//Go through each sections in the main report and identify the subreport by name
   crSections = crReportDocument.ReportDefinition.Sections;

   foreach(Section crSection in crSections)
   {
    crReportObjects = crSection.ReportObjects;
    //loop through all the report objects to find all the subreports
    foreach(ReportObject crReportObject in crReportObjects)
    {
     if (crReportObject.Kind == ReportObjectKind.SubreportObject)
     {
      //you will need to typecast the reportobject to a subreport
      //object once you find it
      crSubreportObject = (SubreportObject)crReportObject;

      //open the subreport object
      crSubReportDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
      //Once the correct subreport has been located pass it the
      //appropriate dataset
      if(crSubReportDoc.Name == "FirstSub")
      {
       //crSubReportDoc.Database.Tables[0].SetDataSource(ds);
       crSubReportDoc.SetDataSource(ds);
      }
     }
    }
   }
   crystalReportViewer1.ReportSource = crReportDocument;

同樣crSubReportDoc.SetDataSource(ds);改為:crSubReportDoc.SetDataSource(ds.Tables["tablename"]);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.