Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Preview of data in Data Source is ok -- Crystal Re Post Reply Post New Topic
Author Message
PGScannell
Newbie
Newbie


Joined: 17 Jan 2011
Location: United States
Online Status: Offline
Posts: 6
Quote PGScannell Replybullet Topic: Preview of data in Data Source is ok -- Crystal Re
    Posted: 17 Jan 2011 at 7:40am
I've been struggling with this all day now.  This is supposed to be so simple.  Create a datasource, create a report object, connect the two, move some fields onto the report detail, and the report should display something.
 
This is in VS 2005 IDE
Here's what happens:  I can create a data source and connect to it.  I can preview the data successfully (In the data Sources window right-click on the table and select Preview Data...).
 
But, when I look at the report object that I have attached to a CrystalReportViewer control, and run the report, I get headings and that's it.
 
In the Crystal Report object, if I click on "Main Report Preview", I get data but it definitely isn't from my database table.  I get colors, days of the week, data types.
 
What am I doing wrong?
 
Thanks in advance,
Jerry
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 18 Jan 2011 at 8:37am

How are you viewing the report in the viewer?  In other words, is the viewer in its own window or is it part of the window where the data is generated?  Have you assigned the viewer's report source to this particular report at design time or are you setting it at run time? 

-Dell
IP IP Logged
PGScannell
Newbie
Newbie


Joined: 17 Jan 2011
Location: United States
Online Status: Offline
Posts: 6
Quote PGScannell Replybullet Posted: 18 Jan 2011 at 9:00am
Dell,
 
the viewer is a control on my main form.  Its report Source is the Crystal Report I created.  That assignment is done at design time.
 
Depending on how I view the data will determine the type of output I get:
1. While in the design of the Crystal Report, if I click on the "Main Report Preview" tab, I get data but it definitely isn't from my database table.  I get crazy text like colors, days of the week, data types.
2. If I build and run the app, the report I get contains the headings and nothing else.
 
Jerry
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 18 Jan 2011 at 10:28am
The Preview in Crystal doesn't actually connect to real data - it's dummy data.
 
Instead of setting everything at design time, try something like this (code is in C# - modify appropriately if you're using VB):
//create a new named instance of the report
MyReport rpt = new(MyReport);
//Set the DataSource of the report to the DataSet defined in your app
//NOTE:  This is NOT the table - it's the whole DataSet
rpt.SetDataSource(MyDataSet);
//Set the ReportSource of the viewer to the report object that you created above.
CrystalRptViewer.ReportSource = rpt;
 
-Dell
IP IP Logged
PGScannell
Newbie
Newbie


Joined: 17 Jan 2011
Location: United States
Online Status: Offline
Posts: 6
Quote PGScannell Replybullet Posted: 18 Jan 2011 at 2:13pm
I can try that tomorrow.
 
Tell me, though, is doing this going to explain why previewing in the Report designed doesn't provide the data from my DB?
 
Jerry
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 19 Jan 2011 at 3:24am
When you preview a report that is connected to a .NET DataSet, the DataSet doesn't really have any data in it.  So, Crystal can get the table structures, but it uses dummy data for the preview display.
 
-Dell
IP IP Logged
PGScannell
Newbie
Newbie


Joined: 17 Jan 2011
Location: United States
Online Status: Offline
Posts: 6
Quote PGScannell Replybullet Posted: 19 Jan 2011 at 4:00am
So you can't preview a report in the designer, then?  How do you know that it is right before you try to implement it?
 
Even if I shouldn't come to any conclusions with the preview, I still have the problem that the report, when run, doesn't show any data, either.  just headings.
 
Finally, in other CR designers that I've used, there is always been a data entry screen where you entered the SQL select statement that the report is to be based on.  There doesn't seem to be that kind of dagta entry screen in VS2005.
 
Is it hidden behind some other menu option?
 
Thanks,
jerry
IP IP Logged
PGScannell
Newbie
Newbie


Joined: 17 Jan 2011
Location: United States
Online Status: Offline
Posts: 6
Quote PGScannell Replybullet Posted: 19 Jan 2011 at 4:01am
As a PS to my last reply, what if the report data was based on a compound select statement with several tables joined together?  There has to be a way to enter that type of SQL query...
 
Jerry
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 19 Jan 2011 at 5:00am
If you're basing your report on table in an in-memory DataSet, you have to select the tables in the DataSet and visually join them in the Database Explorer in the report.  Crystal will then build the SQL based on the DataSet.  At design time, these tables don't have any data in them and your application will have to run the queries that fill the tables in the DataSet prior to running the report.
 
If you want to connect your report directly to the database, you can use the "Add Command" functionality in the Database Explorer if Crystal allows commands for the type of database you're using.
 
-Dell
IP IP Logged
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.031 seconds.