简体   繁体   English

水晶报表:无法打开连接

[英]Crystal report: failed to open connection

My database is a remote Mysql database, I'm able to access the crystal reports of my application through various PC's but there is a problem with one PC, Even though I installed mysql connector and created a connection with my database which was successful using ODBC. 我的数据库是一个远程Mysql数据库,我可以通过各种PC访问应用程序的水晶报表,但是一台PC还是有问题,即使我安装了mysql连接器并与我的数据库建立了连接,但使用ODBC成功。 But while I load the report it displays a message "Failed to open connection" 但是当我加载报告时,它会显示一条消息“无法打开连接” 在此处输入图片说明

I have used the following code for the manual connection: 我将以下代码用于手动连接:

cI.ServerName = "Driver={MySQL ODBC 5.3 Unicode Driver};Server=x.x.x.x;Port=3306;Option=3;";
            cI.DatabaseName = "dbName";
            cI.UserID = "username";
            cI.Password = "pass";

            foreach (IConnectionInfo info in report.DataSourceConnections)
            {
                info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
            }

            foreach (ReportDocument sub in report.Subreports)
            {
                foreach (IConnectionInfo info in sub.DataSourceConnections)
                {
                    info.SetConnection(cI.ServerName, cI.DatabaseName, cI.UserID, cI.Password);
                }
            }

I get this exception: 我得到这个例外:

    System.Runtime.InteropServices.COMException (0x800002F4): Failed to open the connection.
Failed to open the connection.
temp_32398d30-5e82-45f2-a356-0abdad3ba4c5 5168_1588_{1AF659C8-D14D-479F-B268-51AD72B9420A}.rpt
   at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)
   at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)
   at School.UserInterface.StudentApp.PrintStudentInformation.connect(ReportDocument report)
   at School.UserInterface.StudentApp.PrintStudentInformation.PrintStudentInformation_Load(Object sender, EventArgs e)
   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.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

After days of struggle, I managed to solve the problem turns out that I had to install MySQL ODBC 32Bit version on the PC which was having this problem, even though that PC already had MySQL ODBC installed but it was 64 bit version. 经过几天的努力,我设法解决了这个问题,结果是我必须在有此问题的PC上安装MySQL ODBC 32Bit版本,即使该PC已经安装了MySQL ODBC但它是64位版本。 So, If anyone is facing a similar problem then I suggest that you should install both versions of MySQL ODBC if your PC is 64 bit PC. 因此,如果任何人都遇到类似的问题,那么如果您的PC是64位PC,则建议您同时安装两个版本的MySQL ODBC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM