Link to home
Start Free TrialLog in
Avatar of ljhodgett
ljhodgett

asked on

show crystal report in crystal report viewer on c# 2005 winform

Hi,

I have created a crystal report that is linked to a dataset. I am trying to find out how I would show this in a c# crystal report viewer contained in a winform. The code I usually use in vb.net is: -

Dim rpt As New crUsage_By_Date




        rpt.Load(Forms.Application.StartupPath & "\crUsage_By_Date.rpt")
        rpt.SetDataSource(DsReports1.Tables("Usage_By_Date"))

        rpt.SetParameterValue("Report_Period", DateTimePicker1.Text & " to " & DateTimePicker2.Text)
        rpt.SetParameterValue("Printed_By", MDIParent1.lblUser.Text)
        'frmPreviewReport.CrystalReportViewer1.ReportSource = rpt
        'frmPreviewReport.Show()

I am trying to find out the c# equivalent.

Many thanks
Lee
Avatar of Smart_Man
Smart_Man
Flag of Egypt image

usually it is quiet the same but for few brackets changed ,,
try some msdn search
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ljhodgett
ljhodgett

ASKER

Hi,

I've put the following code into my form:-

            CrystalDecisions.CrystalReports.Engine.ReportDocument crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            String path = Environment.CurrentDirectory;
            crReportDocument.Load(path + @"\crProgressReport.rpt");
            crReportDocument.SetDataSource(myDSMeasurements.Tables["dtMeasurements"]);
            crystalReportViewer1.ReportSource = crReportDocument;

but it comes up Load report failed on crReportDocument.Load(path + @"\crProgressReport.rpt"); the path variable seems to be correct and the rpt is contained within the directory. Unfortunately it doesn't give me any more information. What am I doing wrong please.

Many Thanks
Lee
What is the purpose of the @ in the Load statement?

mlmcc
waiting for your reply
Hi,

For some reason it's not working on my development pc but it's ok on my laptop. I'm having quite a few issues with visual studio on my development pc so I think I need a fresh install.

Best regards
Lee