Failed to load report error message using crystal report .net and c# 2005

Hi,

I have the following code that opens a crystal report and displays it in the viewer on the winform: -

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace Slimming
{
    public partial class frmProgressReport : Form
    {
        protected CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument1;

        public frmProgressReport()
        {
            InitializeComponent();
        }

        private void frmProgressReport_Load(object sender, EventArgs e)
        {
            lblUser.Text = Program.frmMain.cmbUsers.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            fraBuilding.Visible = true;
            dsMeasurements myDSMeasurements = new dsMeasurements();
            //Create connection to mdf sql file
            System.Data.SqlClient.SqlConnection con2 =
                new System.Data.SqlClient.SqlConnection(
                @"Data Source=.\sqlexpress;AttachDbFilename=|DataDirectory|\MainDB.mdf;Integrated Security=True;User Instance=True");

            //Create new data adapter and perform query
            System.Data.SqlClient.SqlDataAdapter da2 = new System.Data.SqlClient.SqlDataAdapter("SELECT     m.UserID, m.Weight, m.DateTaken, ISNULL(m.Weight - p.Weight, 0) AS 'Gain / Loss' FROM Measurements AS m LEFT OUTER JOIN Measurements AS p ON p.UserID = m.UserID AND p.DateTaken = (SELECT MAX(DateTaken) AS Expr1 FROM Measurements AS mm WHERE (DateTaken < m.DateTaken)) WHERE (m.UserID = '" + globalclass.userID.ToString() + "') ORDER BY m.DateTaken DESC", con2.ConnectionString);

            // place result into fixed dataset
            da2.Fill(myDSMeasurements, "dtMeasurements");

            String path = Environment.CurrentDirectory;

            //show crystal report and bind dataset to report
            ReportDocument rpt = new ReportDocument();
            rpt.Load(@"H:\crtest.rpt");
            rpt.SetDataSource(myDSMeasurements.Tables["dtMeasurements"]);
            crystalReportViewer1.ReportSource = rpt;


        }
    }
}

When I click button1 it comes up with the error message on the line rpt.Load(@"H:\crtest.rpt"); : -



System.Exception was unhandled
  Message="Load report failed."
  Source="CrystalDecisions.CrystalReports.Engine"
  StackTrace:
       at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
       at Slimming.frmProgressReport.button1_Click(Object sender, EventArgs e) in H:\Documents and Settings\Administrator\Desktop\Slimming3\frmProgressReport.cs:line 46
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Slimming.Program.Main() in H:\Documents and Settings\Administrator\Desktop\Slimming3\Program.cs:line 24
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()



what am I doing wrong please.

Many Thanks
Lee
ljhodgettAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MIKESoftware Solutions ConsultantCommented:
What "error" are you getting...???

MIkeV
0
ljhodgettAuthor Commented:
Hi Mike,

It just comes up with the error message:

System.Exception was unhandled
  Message="Load report failed."
  Source="CrystalDecisions.CrystalReports.Engine"
  StackTrace:
       at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
       at Slimming.frmProgressReport.button1_Click(Object sender, EventArgs e) in H:\Documents and Settings\Administrator\Desktop\Slimming3\frmProgressReport.cs:line 46
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Slimming.Program.Main() in H:\Documents and Settings\Administrator\Desktop\Slimming3\Program.cs:line 24
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()




When it gets to the line  rpt.Load(@"H:\crtest.rpt");. It doesn't actually say anything else. Is there a way to get more detail?

Best Regards
Lee
0
mlmccCommented:
Is this on the development machine or a client?

What is the @ for in the Load function?

mlmcc
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

ljhodgettAuthor Commented:
Its on the development machine. Sorry I'm new to c#. I seemed to needed the @ at the begining otherwise it would come up with the error message: -

Error      1      Unrecognized escape sequence

Best Regards
Lee
0
ljhodgettAuthor Commented:
Hi,

I've just tried it on another development pc and it works correctly but not on my main development pc. Has anyone got a clue why?

Best Regards
Lee
0
mlmccCommented:
Check the differences in options in the compiler.

You might have to use \\ on your machine.

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.