我使用Oracle 11g& amp ;;在C#4.0中开发了一个桌面应用程序。用于VS 2010的Crystal报告
它执行&在开发机器和运行中运行良好我创建了一个设置文件
在客户端系统中我安装了oracle客户端和我的应用程序的安装文件
能够很好地使用该应用程序,直到我生成任何水晶报告。它显示以下屏幕截图
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)
2即使我点击继续询问我的服务器用户名&密码如下
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);
}
对于第一个屏幕,我无法理解......
请帮助。
答案 0 :(得分:1)
要获取包含当前程序的目录,最好执行以下操作:
System.IO.Path.GetDirectory(System.Reflection.Assembly.GetExecutingAssembly().Location)
由于您在该目录中有一个要加载的文件,因此更清晰/更易读的方法是这样的:
string directoryContainingTheExecutable = System.IO.Path.GetDirectory(System.Reflection.Assembly.GetExecutingAssembly().Location);
string reportPath = System.IO.Path.Combine(directoryContainingTheExecutable, "VisitorIDReport.rpt");
组合功能可确保路径正确组装。这意味着你不必担心像C:\ Program Files \ MyProgram \ MyFile.rpt这样的东西。或者,如果您的程序在Linux环境中使用,则不必使用forwardslashes替换所有反斜杠。