Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在客户端计算机中获取Crystal报告错误_C#_.net_Winforms_Oracle_Crystal Reports - Fatal编程技术网

C# 在客户端计算机中获取Crystal报告错误

C# 在客户端计算机中获取Crystal报告错误,c#,.net,winforms,oracle,crystal-reports,C#,.net,Winforms,Oracle,Crystal Reports,我用Oracle11g和Vs2010的CrystalReport在C#4.0中开发了一个桌面应用程序 它在开发机器中运行良好&我创建了一个安装文件 在客户端系统中,我安装了oracle客户端和应用程序的安装文件 能够很好地使用该应用程序,直到我生成任何crystal报告。首先,它会显示下面的屏幕截图 at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(

我用Oracle11g和Vs2010的CrystalReport在C#4.0中开发了一个桌面应用程序

它在开发机器中运行良好&我创建了一个安装文件

在客户端系统中,我安装了oracle客户端和应用程序的安装文件

能够很好地使用该应用程序,直到我生成任何crystal报告。首先,它会显示下面的屏幕截图

   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)

第二,即使我单击“继续”,其询问我服务器用户名和密码如下

private void VisitorIDReportWindow_Load(object sender, EventArgs e)
    {
        if (this.CON.State.Equals(System.Data.ConnectionState.Open))
        {
            CON.Close();
        }
        CON.Open();

        DataTable DTB;
        string query1 = "Select * from VMS_VISITOR where PASSNUMBER ='" + VisitorCreationWindow.PNBR + "'";

        using (OLCMND1 = new OracleCommand(query1, CON))
        {
            using (OADAP1 = new OracleDataAdapter(OLCMND1))
            {
                DTB = new DataTable();
                OADAP1.Fill(DTB);
            }
        }

        RDT = new ReportDocument();
        string reportpath = System.Windows.Forms.Application.StartupPath.Substring(0,System.Windows.Forms.Application.StartupPath.Substring(0,System.Windows.Forms.Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
        reportpath += @"\VisitorIDReport.rpt";   //string reportpath = "D:\\Visitor Management System\\Visitor Management System\\VisitorIDReport.rpt";
        RDT.Load(reportpath);

        ConnectionInfo connectioninfo = new ConnectionInfo();
        connectioninfo.DatabaseName = "ORCL";
        connectioninfo.UserID = "itapps";
        connectioninfo.Password = "it123";

        Logindetailforreport(connectioninfo,RDT);
        VisitorIDCrystalReportViewer.ReportSource = RDT;

        RDT.SetDataSource(DTB);            
    }

对于第一屏,我不知道该怎么做


请提供任何帮助。

要获取包含当前程序的目录,最好执行以下操作:

System.IO.Path.GetDirectory(System.Reflection.Assembly.Ge‌​tExecutingAssembly().Location)
string directoryContainingTheExecutable = System.IO.Path.GetDirectory(System.Reflection.Assembly.Ge‌​tExecutingAssembly().Location);
string reportPath = System.IO.Path.Combine(directoryContainingTheExecutable, "VisitorIDReport.rpt");
由于您在该目录中有一个要加载的文件,因此更干净/更可读的方法如下:

System.IO.Path.GetDirectory(System.Reflection.Assembly.Ge‌​tExecutingAssembly().Location)
string directoryContainingTheExecutable = System.IO.Path.GetDirectory(System.Reflection.Assembly.Ge‌​tExecutingAssembly().Location);
string reportPath = System.IO.Path.Combine(directoryContainingTheExecutable, "VisitorIDReport.rpt");

联合收割机功能确保正确组装路径。这意味着您不必担心C:\Program Files\MyProgram\MyFile.rpt之类的问题。或者,如果您的程序在Linux环境中使用,您不必将所有反斜杠替换为正向斜杠。

不完全确定错误,但您是否尝试在新机器上打印
System.Windows.Forms.Application.StartupPath
的值?嗯,您可能应该使用类似于
string reportPath=System.IO.Path.Combine(System.IO.Path.GetDirectory(System.Reflection.Assembly.getExecutionGassembly().Location)),“visitorReport.rpt”)不应“手动”构建路径。特别是不是通过硬编码反斜杠。哦,关于登录框:根据我的经验,CrystalReports至少丢失了一个报表参数时,该框就会弹出。@SteffenWinkler我尝试了你的代码,但它为reportpath提供了“已识别的预期”,你能告诉我丢失了什么参数吗?哦,有一个结束括号太多。只需移除位置后面的第二个。如果出现例外情况,则可能需要所有参数和/或文档路径。