Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 4 and Visual Studio 2010 > BOOK: Professional Visual Studio 2010
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Visual Studio 2010
This is the forum to discuss the Wrox book Professional Visual Studio 2010 by Nick Randolph, David Gardner, Chris Anderson, Michael Minutillo; ISBN: 9780470548653
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Visual Studio 2010 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 24th, 2010, 06:47 PM
Registered User
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 30 questions and Issues

I want to create a basic "this works and I can modify it once I get it working"
report. As it followed the chapter I ran into some problems.

Basically 2 things

1. In Generating the Report the is no mention of the fact that if creating a report by hand or adding it to an existing project this using needs to be added.
Code:
using Microsoft.Reporting.WinForms;
Also from searching the net it looks like the Report1.rdlc should have a BuildAction property set to "Embedded Resource"


2. I am using C# chose to embed the report. I added the 4 example lines from this section
Code:
LocalReport reportEngine = reportViewer1.LocalReport;
reportEngine.ReportEmbeddedResource = "Test4.Report1.rdlc";
reportEngine.DataSources.Add(new ReportDataSource("CustomerData",data));
reportViewer1.RefreshReport();
When creating the report the namespace was "Test4"
and I accepted all the default names as I followed the chapter.

I did create my own xsd file "APM.xsd" that has a datatable object named "apmast01" and a TableAdapter object named "apmast01TableAdapter". The TableAdapter is based on a SelectCommand. I do not want to use the Entity Framework at this point

It no problem with lines 1, 2 and 4
But I do NOT understand what is supposed to be used in line 3.
Obviously it is not "CustomerData" and data but what should it be?
Reply With Quote
  #2 (permalink)  
Old January 21st, 2011, 10:35 AM
Authorized User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Arkay

When instantiating a ReportDataSource object (as per this line):

Code:
reportEngine.DataSources.Add(new ReportDataSource("CustomerData",data));
You are passing it the name of the data source that you created in the report ("CustomerData") (as per the section titled Defining Data Sources), and then the collection of objects that you wish to pass to your report and populate it with (data). This collection must have previously been populated in your code. I stated that my example was populating the "data" collection variable with data from the Entity Framework, but this can be from any source (such as your XML file) and of any format - as long as it is a collection.

Hope this helps...

Chris
__________________
Chris Anderson
Co-author
Reply With Quote
  #3 (permalink)  
Old April 27th, 2012, 05:57 AM
Authorized User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data variable - chapter 30

Chris, can you show an example of a VB code to create the data collection variable that populates such data from an Entity Framework? Thanks.
Reply With Quote
  #4 (permalink)  
Old April 27th, 2012, 06:35 AM
Authorized User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For example:

Code:
Dim qry = From co In context.SalesOrderHeaders
          Where co.CustomerID = customerID AndAlso co.OrderDate > fromDate
          Select co

e.DataSources.Add(New ReportDataSource("OrderData", qry))
__________________
Chris Anderson
Co-author
Reply With Quote
  #5 (permalink)  
Old April 27th, 2012, 09:34 AM
Authorized User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default I get error

Thank you for your quick response. I get this error. Please advise, thanks.
"An error has occurred during report processing.
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection."
Code:
 Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim reportEngine As LocalReport = ReportViewer1.LocalReport
        reportEngine.ReportPath = "ReportMaster.rdlc"
        Using Context As New teconcrete_TEdbModel.teconcrete_TEdbEntities()
            Dim qry = From co In Context.Tests
            Select co
            reportEngine.DataSources.Add(New ReportDataSource("DataSet1", qry))
        End Using

    End Sub

Last edited by fbuxo; April 27th, 2012 at 12:38 PM.
Reply With Quote
  #6 (permalink)  
Old April 27th, 2012, 09:37 AM
Authorized User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error:

An error has occurred during report processing.
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

Last edited by fbuxo; April 27th, 2012 at 12:35 PM.
Reply With Quote
  #7 (permalink)  
Old April 28th, 2012, 09:24 PM
Authorized User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

LINQ queries have a delayed execution, and you're disposing of the object context before the query is being executed (by wrapping it in a Using block). You can force it to execute immediately by adding a ToList() or ToArray() to the end of the query. For example:

reportEngine.DataSources.Add(New ReportDataSource("DataSet1", qry.ToArray()))
__________________
Chris Anderson
Co-author
Reply With Quote
  #8 (permalink)  
Old April 29th, 2012, 06:42 AM
Authorized User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Report remains loading without showing data

The report remains loading without showing data, in a permanent loop. Do I have to add something to my code something as "If Not Is postback"?. How that code would look like?
My report is based on an entity dataset that calls a select query stored procedure function, TEdbEntitites(GetTests). Does that change the way the query should be written? As for example
Code:
Dim qry = myEntities.GetTests()
. Please advise, thank you very much for your help.

Code looks like this:
Code:
Dim reportEngine As LocalReport = ReportViewer1.LocalReport
reportEngine.ReportPath = "ReportMaster.rdlc"
Using myEntities As New TEdbModel.TEdbEntities()
            Dim qry = From test In myEntities.Tests
            Select test
            ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSetT", qry.ToList()))
        End Using

Last edited by fbuxo; April 29th, 2012 at 08:24 AM.
Reply With Quote
  #9 (permalink)  
Old April 29th, 2012, 08:03 AM
Authorized User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know why you'd be getting in a loop. Have you tried stepping through the code to see why it's getting stuck. You can try sending me your project to christhecoder AT gmail and I can take a look. However, I'm on quite a tight schedule at the moment, so I can't guarantee I'll be able to look at it immediately.
__________________
Chris Anderson
Co-author
Reply With Quote
  #10 (permalink)  
Old April 29th, 2012, 09:22 AM
Authorized User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Still need some help, thanks.....

I was able to stop the infinite looping and now the master report is loading perfect. Nevertheless, the subreport won't show. Please advise. Thank you very much!!
Here is the complete code:
Code:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.Reporting.WebForms
Imports TEdbModel



Partial Class Reports_ReportWeb
    Inherits System.Web.UI.Page
   
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf ProcessSubreport
        If Not IsPostBack Then
            Dim reportEngine As LocalReport = ReportViewer1.LocalReport
            reportEngine.ReportPath = "ReportMaster.rdlc"
            Using myEntities As New TEdbModel.TEdbEntities()
                Dim qry = From r In myEntities.Tests
                Select r
                ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSetT", qry.ToArray()))
            End Using
            Validate()
        End If

    End Sub

    Private Sub ProcessSubreport(ByVal sender As System.Object, ByVal e As SubreportProcessingEventArgs)


        Dim cylinderid As Integer = Convert.ToInt32(e.Parameters("CylinderID").Values(0))
        Using Context As New TEdbModel.TEdbEntities()

            Dim qry = From r In Context.Cylinders
            Where (r.CylinderID = cylinderid)
                    Select r
            e.DataSources.Add(New ReportDataSource("DatasetC", qry.ToArray()))
        End Using
    End Sub


End Class

Last edited by fbuxo; April 29th, 2012 at 09:25 AM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Management Chapter Listing 8-30 jayeshsatam BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 1 July 2nd, 2010 01:25 PM
Questions and Issues Chapters 3 and 4 egoodenuf BOOK: Beginning Spring Framework 2 ISBN: 978-0-470-10161-2 0 October 3rd, 2009 05:09 PM
Chapter 30, Registering Component Services slginps BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 1 April 25th, 2009 01:24 PM
Chapter 7 Workflow setup issues and questions tdewey BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 3 April 20th, 2009 11:22 PM
Chapter 4 issues HenryT BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 June 9th, 2004 02:49 PM



All times are GMT -4. The time now is 10:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.