Noob help - Loading a report from a SQL database & displaying it

Stimulsoft Reports.WPF discussion
Post Reply
Jenner
Posts: 3
Joined: Mon Jun 28, 2010 5:22 pm
Location: USA

Noob help - Loading a report from a SQL database & displaying it

Post by Jenner »

I have just discovered Stimulsoft Reports and am fooling around with some samples to see if I can make this work, but so far I'm not having much luck. I'm sure I'm missing something very basic here.

I am trying to load up a report that just shows employee last names and first names from a SQL database table. In my WPF test application I am calling the following:

Code: Select all

private StiReport report = new StiReport();
        
        public EmployeeWindow()
        {
            InitializeComponent();
            
            report.Load("..\\..\\employee\\emplist.mrt");

            report.RegData("employee", empHelp.GetEmployeesIEnum(ACTIVE));
            report.ShowWithWpf();
        }
empHelp is a helper class, and GetEmployeesIEnum(ACTIVE) returns an IEnumerable list of active employees. When I debug this the program hangs on the RegData function. What am I doing wrong? The above code was basically lifted from the Stimulsoft example applications that I've downloaded. I know that GetEmployeesIEnum works because I've used that function on a DataGrid and the grid is filled in properly with data from my table.

The emplist.mrt report may be malformed, I suppose. All this report has is one data band that contains two columns: employee.lname and employee.fname. These are defined in a Dictionary data set for the report of type "User Sources." (that is, I didn't link the data source to our SQL DB, I just specified column names. I want to load these at run time).

Am I going about this the wrong way? If so, can someone point me to some help? Much appreciated.
ssaturn
Posts: 13
Joined: Mon Jun 07, 2010 5:05 am
Location: Malaysia

Noob help - Loading a report from a SQL database & displaying it

Post by ssaturn »

Hi,

I am using this method to passing the parameter into the Report.
Me.stiReport1.Load(Me.cboxReports.SelectedItem.ReportPath)
Me.stiPreviewControl1.Report = stiReport1

Dim EventDateStart As DateTime = New DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, 6, 0, 0)
Dim EventDateEnd As DateTime = New DateTime(SelectedDateEnd.Year, SelectedDateEnd.Month, SelectedDateEnd.Day, 5, 59, 59).AddDays(1)

Me.stiReport1.Item("ReportDate") = EventDateStart.ToString("dd MMM yyyy, h:mm tt")
Me.stiReport1.Item("ReportDateEnd") = EventDateEnd.ToString("dd MMM yyyy, h:mm tt")

Me.stiReport1.RenderWithWpf(True)
Me.stiPreviewControl1.InvokeZoomOnePage()
Regards,
John
Jenner
Posts: 3
Joined: Mon Jun 28, 2010 5:22 pm
Location: USA

Noob help - Loading a report from a SQL database & displaying it

Post by Jenner »

I see that you are loading a couple of DateTimes into the report, but what is the method for loading IEnumerable or IQueryables? I see that this is done in the Stimulsoft example appliations, but it doesn't work for me. I need to take a bunch of LinqtoSql table objects and throw them at the report and have it render. As far as I know this is entirely doable, but I need some help with the details.

ssaturn wrote:Hi,

I am using this method to passing the parameter into the Report.
Me.stiReport1.Load(Me.cboxReports.SelectedItem.ReportPath)
Me.stiPreviewControl1.Report = stiReport1

Dim EventDateStart As DateTime = New DateTime(SelectedDate.Year, SelectedDate.Month, SelectedDate.Day, 6, 0, 0)
Dim EventDateEnd As DateTime = New DateTime(SelectedDateEnd.Year, SelectedDateEnd.Month, SelectedDateEnd.Day, 5, 59, 59).AddDays(1)

Me.stiReport1.Item("ReportDate") = EventDateStart.ToString("dd MMM yyyy, h:mm tt")
Me.stiReport1.Item("ReportDateEnd") = EventDateEnd.ToString("dd MMM yyyy, h:mm tt")

Me.stiReport1.RenderWithWpf(True)
Me.stiPreviewControl1.InvokeZoomOnePage()
Regards,
John
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Noob help - Loading a report from a SQL database & displaying it

Post by Jan »

Hello John,

Please check attached sample project.

Thank you.
Attachments
471.Linq.zip
(33.62 KiB) Downloaded 349 times
Jenner
Posts: 3
Joined: Mon Jun 28, 2010 5:22 pm
Location: USA

Noob help - Loading a report from a SQL database & displaying it

Post by Jenner »

This was one of the examples I have used to guide me, yes. I still cannot get it to work. Would any other information from me help troubleshoot? It seems like the issue may be with the report file itself, but I don't know how I should properly format it to allow me to set the data content at runtime. As I said, I've set a user-defined datasource in the report and specified a couple of text columns for the data I want to import. Do I have to do something else special to get this to work?

Here is my code based on your Linq example project:

Code: Select all

public CMSClassesDataContext db;
        
        
        public EmployeeWindow()
        {
            InitializeComponent();
            report.Load("..\\..\\Employee\\emplist.mrt");

            db = new CMSClassesDataContext();
            var employees = from p in db.employees
                            where p.status == '1'
                            orderby p.lname
                            select p;

            report.RegData("employees", employees);
            report.ShowWithWpf();
        } 
Jan wrote:Hello John,

Please check attached sample project.

Thank you.
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Noob help - Loading a report from a SQL database & displaying it

Post by Andrew »

Hello,

Could you please send us a code you use or a sample project for testing to support@stimulsoft.com

Thank you.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Noob help - Loading a report from a SQL database & displaying it

Post by Jan »

Hello,

Please check our answer on your EMail.

Thank you.
Post Reply