|
 |
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 .
|
 |
|
|
 |
|

September 24th, 2010, 06:47 PM
|
Registered User
|
|
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|

January 21st, 2011, 10:35 AM
|
Authorized User
|
|
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 27th, 2012, 05:57 AM
|
Authorized User
|
|
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

April 27th, 2012, 06:35 AM
|
Authorized User
|
|
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 27th, 2012, 09:34 AM
|
Authorized User
|
|
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

April 27th, 2012, 09:37 AM
|
Authorized User
|
|
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

April 28th, 2012, 09:24 PM
|
Authorized User
|
|
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 29th, 2012, 06:42 AM
|
Authorized User
|
|
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

April 29th, 2012, 08:03 AM
|
Authorized User
|
|
Join Date: Aug 2010
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 29th, 2012, 09:22 AM
|
Authorized User
|
|
Join Date: Apr 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |
All times are GMT -4. The time now is 10:41 AM.
|