kumartyr
kumartyr

Reputation: 305

getting Crystal Report error in client machine

I developed a desktop application in C# 4.0 with Oracle 11g & used Crystal report for VS 2010

it executing & running fine in developement machine & i created a setup file

In client system i installed oracle client and setup file of my application

able to use the application well until i generate any crystal report ..1st it display the below screen shot

enter image description here

   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)

2nd even if i click continue its asking me server username & password like below

enter image description here

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

And for 1st screen i am not able to get any idea..

Any help please.

Upvotes: 0

Views: 1042

Answers (1)

Steffen Winkler
Steffen Winkler

Reputation: 2864

To get the directory that contains the current program, it's better to do something like this:

System.IO.Path.GetDirectory(System.Reflection.Assembly.Ge‌​tExecutingAssembly().Location)

Since you've a file inside that directory that you want to load, a much cleaner/more readable approach would be something like this:

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

The Combine function makes sure that the path is correctly assembled. Meaning you don't have to worry about something like C:\Program Files\MyProgram\MyFile.rpt. Or, in case your program is used in a Linux environment, you won't have to replace all backslashes with forwardslashes.

Upvotes: 1

Related Questions