1
我的數據庫是一個遠程Mysql數據庫,我可以通過各種PC訪問我的應用程序的水晶報告,但是一臺PC出現問題,即使我安裝了mysql連接器並創建了與我的數據庫連接使用ODBC成功。但是,當我打開它顯示一條消息,報告「無法打開連接」 Crystal report:未能打開連接
我用下面的代碼爲手動連接:
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)
你有沒有檢查過,這臺PC上的虛擬報告是否開放?或者這只是本報告的一個問題? –
你能調試和看到異常的細節 – aMazing
@ItiTyagi從這個數據庫中的所有報告都造成這個問題 –