首页 文章

Crystal报告:无法打开连接

提问于
浏览
1

我的数据库是一个远程的Mysql数据库,我'm able to access the crystal reports of my application through various PC'但是有一台PC有问题,即使我安装了mysql连接器并且创建了与我的数据库连接成功使用ODBC . 但是当我加载报告时,它会显示一条消息"Failed to open connection"
enter image description here

我使用以下代码进行手动连接:

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);
                }
            }

我得到这个例外:

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)

1 回答

  • 0

    经过几天的奋斗,我设法解决问题,原来我必须在有这个问题的PC上安装MySQL ODBC 32Bit版本,即使该PC已经安装了MySQL ODBC但它是64位版本 . 所以,如果有人遇到类似的问题,那么我建议你应该安装两个版本的MySQL ODBC,如果你的PC是64位PC .

相关问题