【发布时间】:2014-04-17 20:43:52
【问题描述】:
我在 C# 4.0 中使用 Oracle 11g 开发了一个桌面应用程序,并使用了 Crystal Report for VS 2010
它在开发机器中执行和运行良好,我创建了一个安装文件
在客户端系统中,我安装了 oracle 客户端和我的应用程序的设置文件
能够很好地使用该应用程序,直到我生成任何水晶报告 ..1st 它显示下面的屏幕截图
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.Windows.Forms.Application.StartupPath的值? -
呃,你可能应该使用类似
string reportPath = System.IO.Path.Combine(System.IO.Path.GetDirectory(System.Reflection.Assembly.GetExecutingAssembly().Location)), "VisitorIDReport.rpt");的东西,你永远不应该“手动”构建路径。特别是不要硬编码反斜杠。 -
哦,还有关于登录框:根据我的经验,只要 CrystalReports 缺少报告的至少一个参数,该框就会弹出。
-
@SteffenWinkler 我试过你的代码,但它给了我报告路径的“IDENTIFIED EXPECTED”,你能告诉我我缺少什么参数吗?
-
哦,多了一个右括号。只需删除位置后面的第二个。考虑到例外情况,可能是所有参数和/或文档路径。
标签: c# .net winforms oracle crystal-reports