Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Report is generated but shows no data Post Reply Post New Topic
<< Prev Page  of 4 Next >>
Author Message
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 08 May 2007 at 1:43pm

I'm using the Report Document object model instead of the Viewer object mode.  My WinForms application has two forms.  One is the main form where the user selects some parameters which then are used to get the data that is saved to the ADO.NET dataset.  The other has the report viewer component and is used to display the report. 

The Creator on the viewer form has been overridden so that the DataSet can be sent to it.  So, the creator looks like this:

private BOEUserAuditRpt auditRpt;

public BOEAuditRptViewer(DataSet dsAuditInfo)
{
  InitializeComponent();
 
auditRpt = new BOEUserAuditRpt();
  auditRpt.SetDataSource(dsAuditInfo);
  auditRptViewer.ReportSource = auditRpt;
}
 
This explicitly sets the datasource of the report object AND the report souce of the viewer object.
 
The code that shows the form looks like this:

private void RunReport()
{
 
BOEAuditRptViewer viewer = new BOEAuditRptViewer(dsAuditInfo);
  viewer.Show();
}
 
-Dell
IP IP Logged
rbblack
Newbie
Newbie
Avatar

Joined: 26 Apr 2007
Location: United States
Online Status: Offline
Posts: 6
Quote rbblack Replybullet Posted: 08 May 2007 at 7:51pm
Would you happen to have that in VB code?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 09 May 2007 at 6:37am
No, sorry!  I only work in C# right now and I've never done anything in VB.
 
-Dell
IP IP Logged
rbblack
Newbie
Newbie
Avatar

Joined: 26 Apr 2007
Location: United States
Online Status: Offline
Posts: 6
Quote rbblack Replybullet Posted: 12 May 2007 at 2:03am

That's cool, I found a C#-VB converter here: http://authors.aspalliance.com/aldotnet/examples/translate.aspx in case anybody else has this problem...I'm going to learn C# anyway since all of the .net code samples for the Amazon Web Service are in C#.

For this project I went ahead and used VS2005's Report Viewer which works like a charm, it just doesn't have as many export options as CR. 
 
I'm just disappointed that the CR Viewer didn't work with the reduced code in VB.  I'm wondering if it's a VB bug or a CR bug or my code (though I followed every step in the tutorials to a tee). 
 
When I get time I'll do this same project in C# and see what happens.  Thanks for all your help Dell.
IP IP Logged
Mike W
Newbie
Newbie


Joined: 28 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote Mike W Replybullet Posted: 28 May 2007 at 9:17am
Hi,
 
I'm suffering from the same problem. . . 
 
I've been unsuccessfully trying to get a report working in a Windows Forms app that I am working on in VS2005/VB.NET.
 
In the end, I decided to try getting it to work using the tutorial data (VB_Win_Data_DataSets).  This worked fine with the xtreme.mdb.  I then created a new dataset schema pointing it at a simple Stored Procedure "SELECT * FROM tblCustomer" in the production SQL Server database.  The data previewed ok.  I then created a new report which simply displayed the data, without any sorting, grouping or filtering.  Finally, I substituted the code in the CustomerDataSet property in the DataSetConfiguration class. 
 
The "myDataSet" dataset is populated (I can iterate thru it and display the data) prior to the customerReport.SetDataSource call.  As with other folks, the report headers are displayed but no data and only a single page. . .
 
Has anyone got any bright ideas please?
 
Best regards
 
Mike W
 
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 May 2007 at 11:42am
What code are you using to set the DataSource of the report and the ReportSource of the viewer?
 
-Dell
IP IP Logged
Mike W
Newbie
Newbie


Joined: 28 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote Mike W Replybullet Posted: 28 May 2007 at 11:43pm
Hi,
 
The code I am using is the standard tutorial sample code in VB_Win_Data_DataSets.
 
Public Class Form1
    Private customerReport As ReportDocument
    Private Sub ConfigureCrystalReports()
        customerReport = New ReportDocument()
        Dim reportPath As String = Application.StartupPath & "\" &  
                                                                                        "Customer.rpt" 
        ' My version of the report displays the CustomerId and name.
        customerReport.Load(reportPath)
        Dim myDataSet As DataSet = DataSetConfiguration.CustomerDataSet
        ' I have placed code to iterate thru myDataSet here and it's
        ' populated with the correct data.
        customerReport.SetDataSource(myDataSet)
        myCrystalReportViewer.ReportSource = customerReport
    End Sub
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
                                               System.EventArgs) Handles MyBase.Load
        ConfigureCrystalReports()
    End Sub
End Class
The only code changes I have made are to the DataSetConfiguration class.
I use the Enterprise Library, both here and in the app I'm developing to populate the dataset and it works fine.
 
 
Imports System.Data
Imports System.Data.OleDb
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.Common
Public Class DataSetConfiguration
    Public Shared ReadOnly Property CustomerDataSet() As DataSet
        Get
            Dim dsCustomer As DataSet = Nothing
            Try
                Dim db As Microsoft.Practices.EnterpriseLibrary.Data.Database=
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase
                Dim sqlCommand As String = "sel_EBCustomer"
                Dim dbCommand As System.Data.Common.DbCommand = db.GetStoredProcCommand(sqlCommand)
                dsCustomer = db.ExecuteDataSet(dbCommand)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            Return dsCustomer
        End Get
    End Property
 
End Class
 
Best regards
 
Mike
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 29 May 2007 at 7:25am
So your original report gets its data from a stored procedure, but what you want to display comes from a local dataset within the application?  That might be part of the problem.... In the report, go to File|Report Options and make sure 'Verify on First Refresh' and 'Verify Stored Procedures on First Refresh' are turned on. 
 
I would also rework the report to run directly from the table instead of from a stored procedure.  There are differences in how Crystal handles data coming from a stored proc vs. data coming from a table.  In your case you're trying to set a table datasource on a report that was designed with a stored proc, which may not work correctly.
 
-Dell
IP IP Logged
Mike W
Newbie
Newbie


Joined: 28 May 2007
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote Mike W Replybullet Posted: 29 May 2007 at 9:57am
I've tried using a dataset template based on both the underlying table and a stored proc which is a simple SELECT * from the table.  I assume this is just used for the schema.  The dataset used at runtime just runs the stored proc that I used in the dataset schema.  I've tried setting the 2 parameters are set on and have recreated the report.  I'm still getting the same report with no data. 
 
Best regards
 
Mike
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 29 May 2007 at 2:38pm
This is a bit confusing, but I'm thinking that there is a disconnect between the first iteration of the report design and using the MS enterprise library for retrieving the dataset. What I would do is call the code for the MS enterprise library and then immediately save it's schema to an XSD file. Then I would build a report just using that XSD file. That ensures that CR is only reading data using that schema and you can preview it ahead of time to make sure it is getting the right data.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
<< Prev Page  of 4 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.032 seconds.