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
tsikilee
Newbie
Newbie
Avatar

Joined: 30 Mar 2008
Location: Finland
Online Status: Offline
Posts: 1
Quote tsikilee Replybullet Posted: 30 Mar 2008 at 8:02am
It's much easier to work straight with the database. I didn't get the report work either with dataset.
IP IP Logged
mitch
Newbie
Newbie
Avatar

Joined: 08 Apr 2008
Location: United States
Online Status: Offline
Posts: 6
Quote mitch Replybullet Posted: 09 Apr 2008 at 11:03am
Hello Brian,
 
I am reading your book, being a newbie. I have created a report with crystal reports that is packaged with VS2005. I have copied it to a share, and and trying to use setdatasource with a dataset created from a sql stored proceedure. It looks like the reportsource is read properly but the data is form the original report query. I think I undersand what you said about using the .xsd, but if we change our application to a different server wouldn't I have to recreate the .xsd on that server?
 
I have been trying to set the datasource on the untyped report but have very unsuccessful. Is the .xsd the only method to do this? How can the original dataset be overritten?
 
thanks
Mitch
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 09 Apr 2008 at 6:05pm
For your first question, you only need the .XSD on the development computer. CR loads the schema into the report file and saves it there permanently. If you change the structure of the dataset file (in ANY way), then you need to create a new XSD and do a Set Datasource Location to force CR to read in the new XSD file.

Re the second question, check the report options and ReportDocument properties to make sure that you aren't saving the data with the report. I've seen other people post similar questions, but this has never happened to me and I don't know the resolution. I make sure I turn off all options to save report data and I use the ReportDocument.SetDataSource() method to load the new dataset into the report (thus overwriting the original dataset)
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
mitch
Newbie
Newbie
Avatar

Joined: 08 Apr 2008
Location: United States
Online Status: Offline
Posts: 6
Quote mitch Replybullet Posted: 10 Apr 2008 at 10:19am
Thanks for the quick reply. I appreciate your time.
 
I have Discard Saved data when loading reports Checked
 
 
 
After more testing, I found that it was actually passing the dataset, but the Report Selection Criteria from the Designer was still executing.
 
I stripped out the Record Select statement and the Grouping out of the Report Designer and put the report back on the share and then the code to pass the dataset works.
 
Now I have to read up on passing/maniplulating Formula Fields, Parameters and RecordSelection formulas.
Anyone have any tips for these?
 
 
Also in the code below
replaced
crpt.SetDataSource(rptDataSet)
with
crpt.SetDataSource(rptDataSet.Tables("ReportQuery"))
 
shouldn't the first way work?
 
 
 
 

    Private Sub cmdPrintPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPrintPreview.Click

 

        Dim strReportName As String = " "

        Dim strDisplayedReportName As String = " "

        Dim strReportPath As String = " "

        Dim SelItem As ListView.SelectedListViewItemCollection

 

        Dim strStoredProcName As String = " "

 

 

        Dim crpt As New ReportDocument

 

        ‘frmReportsViewer has CrystalReportsViewer1

        Dim objfrmReportViwer As New frmReportsViewer

 

        Dim rptDataSet As New DataSet()

        Dim rptDataAdapter As New SqlDataAdapter()

        Dim rptcommand As New SqlCommand()

        Dim rptconnect As New SqlConnection()

 

 

        'Check to see if user has selected a displayed report name from the list, then get the actual report name

        Try

            SelItem = Me.lvReportNames.SelectedItems

            If Me.lvReportNames.SelectedItems.Count = 0 Then

                MessageBox.Show("Please select Report and then click Print.")

                Exit Sub

            Else

                strDisplayedReportName = RTrim(SelItem(0).SubItems(0).Text)

            End If

 

            strReportName = RTrim(GetReportName(strDisplayedReportName))

 

        Catch ex As Exception

            MessageBox.Show("Report Selection error. cmdPrintPreview_Click")

            MessageBox.Show(ex.ToString, C_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error)

            Call Close()

        End Try

 

        strStoredProcName = "usp_" & strReportName

 

        Try

 

            rptconnect = New SqlClient.SqlConnection(gstrCNNString)

 

            rptcommand = New SqlClient.SqlCommand(strStoredProcName, rptconnect)

 

            With rptcommand

                .Connection = gcnnSQLConnection

                .CommandType = CommandType.StoredProcedure

                .CommandText = "usp_" & strReportName

            End With

            rptconnect.Open()

            rptDataAdapter.SelectCommand = rptcommand

 

            rptDataAdapter.Fill(rptDataSet, "ReportQuery")

 

            rptconnect.Close()

            ‘Returns the correct number of rows from SQL Server stored proc

            MessageBox.Show(rptDataSet.Tables.Item("ReportQuery").Rows.Count)

 

        Catch ex As Exception

            MessageBox.Show("Data retrieval error. cmdPrintPreview_Click")

            MessageBox.Show(ex.ToString, C_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error)

            Call Close()

        End Try

 

        'Check to see if the data retrieval returned rows.

        Try

 

            If rptDataSet.Tables.Item("ReportQuery").Rows.Count = 0 Then

                MessageBox.Show("No data returned for your report. Check report paramters and expand criteria if applicable.")

                'Me.Close()

                'Me.Dispose()

                Exit Sub

            Else

 

                ' Data found run the report

                strReportPath = c_REPORTNAMEPATH & RTrim(strReportName) & ".rpt"

 

                If Not IO.File.Exists(strReportPath) Then

                    MessageBox.Show("No Path")

                End If

 

                ‘It loads the report from a shared dir correctly

                crpt.Load (strReportPath)

                crpt.Refresh()

                ‘Doesn’t load the dataset into the report.

                crpt.SetDataSource(rptDataSet)

 

                rptDataSet.Dispose()

                rptDataAdapter.Dispose()

 

                With objfrmReportViwer

                    .CrystalReportViewer1.ReportSource = crpt

                    .Refresh()

                    .Show()

                End With



Edited by mitch - 10 Apr 2008 at 2:07pm
IP IP Logged
sarah7
Newbie
Newbie
Avatar

Joined: 25 Mar 2009
Location: Canada
Online Status: Offline
Posts: 4
Quote sarah7 Replybullet Posted: 25 Mar 2009 at 1:13pm
Hi
I, too, am new to this and am having trouble getting data from a single table into a crystal report.  I have set up a small test database with a few tables and some dummy data.  I've defined a data set as the source for my Visual Studio 2008 project.  The data set appears to be getting filled correctly from my database, as I can right click on a table in the Visual Studio Data Sources window, select Preview Data - and there it is.  But when I define the Data Source Location in the crystal report to be that data set, and preview it - I am picking up some default data from somewhere with days of the weeks, colours of the rainbow (Grey, Green Blue Lime  etc.)  When I execute my application (which does nothing yet except kick off a Crystal Report Viewer) the table appears in Form1 but with no data.  I am stumped, please help.
IP IP Logged
mitch
Newbie
Newbie
Avatar

Joined: 08 Apr 2008
Location: United States
Online Status: Offline
Posts: 6
Quote mitch Replybullet Posted: 25 Mar 2009 at 2:14pm
I ran in this too, pretty common I think.  Try going into Field Explorer -> under Database Fields -> Right click and chose Set Datasource Location. You'll have to drill down to your table or query for your server. Hope this helps.
IP IP Logged
sarah7
Newbie
Newbie
Avatar

Joined: 25 Mar 2009
Location: Canada
Online Status: Offline
Posts: 4
Quote sarah7 Replybullet Posted: 25 Mar 2009 at 3:18pm
Hi Mitch
I checked Database Fields in the Field Explorer, and it is correctly set to point to the appropriate table in my Dataset.  So it must be something else, any more ideas?
Thanks
IP IP Logged
mitch
Newbie
Newbie
Avatar

Joined: 08 Apr 2008
Location: United States
Online Status: Offline
Posts: 6
Quote mitch Replybullet Posted: 25 Mar 2009 at 3:43pm
Hi Sarah7
Sorry, these are under Field Explorer. From Crystal Reports -> Field Explorer. Right click on Database Fields -> Set Datasource Location
 
Connect to your database and table. I had to play with those setting till I was able to set my datasource from there.
Then under Set Datasource Location under properties I manually changed the Provider: SQLOLEDB, Data Source: 'my server name' , Inital Catalog: 'my table name'
I am using SQL Server.


Edited by mitch - 25 Mar 2009 at 3:58pm
IP IP Logged
sarah7
Newbie
Newbie
Avatar

Joined: 25 Mar 2009
Location: Canada
Online Status: Offline
Posts: 4
Quote sarah7 Replybullet Posted: 25 Mar 2009 at 3:59pm
 
Hi Mitch:
 
I don't have those options.  Under Set Datasource Location...Current Data Source: I only have report, not server.
 
Under report ->sarahDataSet Properties I have:
Database Type: ADO.NET
Internal Connection ID: {some hex stuff}
Class Name: WindowsApplication1.sarahDataSet
 
One other thing, just now I set up a new project, using the same procedure for defining my data source as before.  Instead of Crystal reporting, I created a Microsoft Report, used Microsoft Report Viewer and added it to my Form.  I was able to execute this and see my data in the report. This gives me some confidence that I have set up the database (SQL server) and the dataset correctly, and the dataset is clearly getting populated.  So somehow I am not configuring or connecting Crystal Reports properly to my dataset.
IP IP Logged
mitch
Newbie
Newbie
Avatar

Joined: 08 Apr 2008
Location: United States
Online Status: Offline
Posts: 6
Quote mitch Replybullet Posted: 25 Mar 2009 at 4:18pm
Hi Sarah7,
Excellent getting your report to connect. do you have a connection setting... from solution Explorer -> right click on your project name - > properties -> Settings ... select type = connection -> click on elipses to set the Value....
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.031 seconds.