簡體   English   中英

在 Crystal Report for Visual Studio 中加載數據庫信息失敗

[英]Failed to Load database information in Crystal Report for Visual Studio

我在使用 VS2013 的 Crystal Reports 時遇到問題。 我有一個在 VS2010 中使用 CR 開發的 Windows 應用程序。

當我嘗試在 VS 2013 中運行它時,出現以下異常:

Failed to load database information.
Error in File BillReport {E3FDAF36-9149-4F03-BCB6-EE66639AFFFB}.rpt:
Failed to load database information.
   at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
   at Stock_Maintanance.PrintBillReport.PrintBillReport_Load(Object sender, EventArgs e) in e:\perforce\DudhatTechnologies\Users\jay vadiya\Stock Maintanance\Release 0.1\Stock Maintanance\PrintBillReport.cs:line 86
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
   at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
   at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.Form.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.Show()
   at Stock_Maintanance.PrintBill.btPrint_Click(Object sender, EventArgs e) in e:\perforce\DudhatTechnologies\Users\jay vadiya\Stock Maintanance\Release 0.1\Stock Maintanance\PrintBill.cs:line 717
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at Stock_Maintanance.Program.Main() in e:\perforce\DudhatTechnologies\Users\jay vadiya\Stock Maintanance\Release 0.1\Stock Maintanance\Program.cs:line 20

以下是我從由 OLEDB 連接填充的 XML 數據集加載水晶報告的代碼

string sqlstr = "";
sqlstr = "select * from billMaster where billid =  " + billId + " and merchantName = '" + merchantName + "' ";
// DataSet ds = m1.selectData(sqlstr);

cmd = new OleDbCommand(sqlstr, m1.ccon);
if (m1.ccon.State == ConnectionState.Closed) {
    m1.ccon.Open();
}
OleDbDataAdapter da = new OleDbDataAdapter(sqlstr, m1.ccon);

BillPrint bp = new BillPrint();

// dr = cmd.ExecuteReader();
da.Fill(bp.billMaster);
sqlstr = "select srNo from billInfo where billId=" + billId + " order by srNo";
DataSet dsTemp = m1.selectData(sqlstr);
sqlstr = "select (srNo+1-" + dsTemp.Tables[0].Rows[0].ItemArray[0].ToString() + ") as srNo,billId,itemType,itemName,length,width,thickness,squareMeter,billRate,Qty,subTotal from billInfo where billId=" + billId;
OleDbDataAdapter da1 = new OleDbDataAdapter(sqlstr, m1.ccon);
// dr = cmd.ExecuteReader();
da1.Fill(bp.billInfo);

string path = "";
path = Application.StartupPath + "\\reports\\BillReport.rpt";

/* if (RateVisible == 1)
{
    path = Application.StartupPath + "\\reports\\BillReport.rpt";
}
else if (RateVisible == 2)
{
    path = Application.StartupPath + "\\reports\\BillReportWithoutRate.rpt";
}*/
//  MessageBox.Show(path);

ReportDocument rd = new ReportDocument();
rd.Load(path);
rd.SetDataSource(bp);
crv.ReportSource = rd;
crv.RefreshReport();

在 app.config 中的<configuration>元素下的代碼下方添加<startup>代碼

<startup useLegacyV2RuntimeActivationPolicy="true"></startup>

我的水晶報表安裝目錄中缺少crdb_adoplus.dll

C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64

我已經以管理員權限重新安裝了 Crystal Report 運行時,然后安裝了crdb_adoplus.dll 報告正在完美打開。

在我的情況下,不需要更改 Web.config/App.config。

您還可以查看此鏈接: https ://answers.sap.com/questions/12948468/cr13-sp26-visual-studio-2019-setdatasource-error-o.html

此問題可能出現在舊版本的crruntimes中。 如果您升級您的版本,您必須為您的處理器架構(x86 或 x64)安裝最新的crruntime ,然后您需要查看它是否有效。 如果不是,我發現此文件夾中缺少許多文件: "C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0"

它必須看起來像這樣。 文件夾路徑

如果您的項目中有水晶報表的 13.0400 版本 DLL,這將是您問題的解決方案。

閱讀本文檔

我在使用 Crystal Reports 時遇到了錯誤“無法加載數據庫信息”。

報告可以在我的機器上運行(作為開發人員並安裝了 Visual Studio),但不能在客戶端機器上運行並顯示列出的錯誤。

我通過執行以下操作修復了錯誤:

  1. 我使用平台 x86 構建了該項目。
  2. 盡管客戶端機器的 Windows 平台是 x64,但我在客戶端機器上安裝了 Crystal Runtime 64 位和 32 位。
  3. 確保每次安裝后重新啟動機器。

做了這些步驟,問題就解決了。 希望它可以幫助你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM