无法在 Crystal Report for Visual Studio 中加载数据库信息

问题描述 投票:0回答:5

我在使用 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();
c# visual-studio crystal-reports
5个回答
13
投票

在 app.config 中的 <startup>

 元素下添加 
<configuration>
 代码

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

7
投票
我的水晶报表安装目录中缺少

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

我已经使用管理员权限重新安装了水晶报表运行时,然后安装了crdb_adoplus.dll。报告完美打开。

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

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


2
投票

此问题可能会出现在旧版本的

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,这将是您问题的解决方案。

阅读此文档


1
投票

我在使用 Crystal Reports 时遇到错误“无法加载数据库信息”。

报告可以在我的计算机上运行(作为开发人员并安装了 Visual Studio),但不能在客户端的计算机上运行并显示列出的错误。

我通过执行以下操作修复了错误:

  1. 我使用 x86 平台构建了该项目。
  2. 尽管客户端计算机的 Windows 平台是 x64,但我在客户端计算机上安装了 Crystal Runtime 64 和 32 位。
  3. 每次安装后请务必重新启动机器。

执行这些步骤,解决了问题。希望对你有帮助。


0
投票

我在将旧应用程序从 4.0 升级到 4.8 并迁移到 VS 2022 时遇到了同样的问题。 我注意到升级 CR 运行时后,C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86 中缺少 crdb_adoplus.dll。 我右键单击安装程序并选择“修复”,这导致丢失的文件被安装在文件夹中,之后一切正常。

© www.soinside.com 2019 - 2024. All rights reserved.