none
How to load Crystal Report in WPF C# using entity data model?

    Question

  • Hi,Guys

    i try to load crystal report in WPF window using entity data model but it doesn't load , how to load it ?

    i used this tutorials but my enviroment is VS2012

    http://www.c-sharpcorner.com/UploadFile/nipuntomar/crystal-report-viewer-in-wpf-part-1/

    this is my code :

     using CrystalDecisions.CrystalReports.Engine;
     using CrystalDecisions.Shared;
     private void crystalReportsViewer1_Loaded(object sender, RoutedEventArgs e)
        {
            ReportDocument report = new ReportDocument();
            report.Load("CrystalReport1.rpt");
            using (cvmakerEntities1 db = new cvmakerEntities1())
            {
                report.SetDataSource(from c in db.cvs
                 select new {c.Full_Name,c.Address,c.E_Mail,c.Activities,c.Birth_Day,c.Courses,c.Education,c.Experience,c.Gender,c.Mobile,c.Nationality,c.Occuptional_Field,c.Personnal_Website,c.photo,c.Skills,c.Tele});
            }
            crystalReportsViewer1.ViewerCore.ReportSource = report;
        } 

    this is code in xml designer

    <Window x:Class="CV_Maker.Report"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clnamespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
        Title="Report" Height="800" Width="800">
    <Grid>
        <my:CrystalReportsViewer HorizontalAlignment="Left" Name="crystalReportsViewer1"
                                 VerticalAlignment="Top" Height="769" Width="792" Loaded="crystalReportsViewer1_Loaded" />
    </Grid>

    what is the problem here ?

    thanks


    Mohamed Safwat Software Developer

    Friday, September 20, 2013 5:41 PM

All replies

  • Hi Guys,

    I reviewed the code snippet you posted. It looks fine.

    1. I thought we should check the version of Crystal Report. We should use the corresponding version Crystal Report for Visual Studio 2012. We can download the Crystal Report from here.

    2. We should make sure the database contained some raw data. And then I suggested you to set breakpoints on Report Viewer Load method to debug this issue and check the Report Source.

    If there is no data in the Report Source. I thought there are some problems occurred when we fetched the data from Crystal Report. Such as the report file’s location is incorrect, the data table did not map the data source and etc…

    If the Report Source has contained data, I thought there are some problems occurred in XAML code.

    On the other hand, Crystal Report is a 3<sup>rd</sup> part component. For this issue, I recommended to consult the Crystal Report support directly, I think they can give more precise troubleshooting.

    # Crystal Report Forums

    http://scn.sap.com/welcome

    Have a nice time.

    Sincerely,


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    20 hours 33 minutes ago
    Moderator