Solved

Feeding Crystal Reports with a dataset from .Net

Posted on 2009-05-03
10
936 Views
Last Modified: 2012-05-06
Hi experts,

I recently posted a very similar question but realised I need to go one step further.  I'm writing a VB.Net application with one or two Crystal Reports incorporated.  I'm using .Net framework 2 and VS2005.

My original question was:  how can I pass my crystal report (rpt) a datatable/dataset from my .Net code?  This was answered by the following: http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx

This works great if the dataset and XSD comes from a database.  But now I need to pass a dataset that does not come from a database.  I build the dataset and datatable within it by collecting data from other sources.  See example below:

            With ds.Tables("InstanceTasks")
                .Columns.Add(New DataColumn("ReportHeading", System.Type.GetType("System.String", True, True)))
                .Columns.Add(New DataColumn("InstanceName", System.Type.GetType("System.String", True, True)))
                .Columns.Add(New DataColumn("TaskCount", System.Type.GetType("System.Int32", True, True)))
            End With

I then manually populate it with data.

My problem is:  if I provide my crystal report with a XSD Schema written from this dataset, it doesn't show under ADO.Net Datasets.

Is there some other way to pass this dataset to my report?

Please help!
0
Comment
Question by:PantoffelSlippers
  • 5
  • 4
10 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 350 total points
Comment Utility
>>This works great if the dataset and XSD comes from a database.  But now I need to pass a dataset that does not come from a database.

If you look at my example, you should see that the dataset is not created from the database. I have no connection to any database in this article.

Search for WriteXmlSchema in the page.
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Hi Eric,

I did notice that yes but I can't get it to work with anyting other than a database!

If fill a dataset from SQL Server and then wite the XSD I can use it in the report - it shows under ADO.Net Datasets.  If I populate the dataset manually and then write the XSD I can't use it in the report - it doesn't show under ADO.Net Datasets.

One other thing I can tell you is that if I add both XSD's to my project (coming from the db and the one not coming from the db), their icons look different!

Please see attached screenshot showing the different icons.

The XSD coming from the database which works well is called "Frikkie.XSD" and the one that I populated manually that does not work at all is called "ReportDataTableDefition.XSD".

I must be doing something wrong with one the 2nd XSD....

Any ideas?

Thanks

Capture.JPG
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 350 total points
Comment Utility
One thing which is really not clear in the article (only mentionned somewhere in the comments at the bottom) is that the schema created by WriteXmlSchema will not name the dataset properly.

Open the .xsd file into notepad and replace its name with the name of your dataset as shown here:
  <xs:element name="TestDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Hi Eric,

Sorry, no.

No luck.  I've taken the XSD that doesn't work and changed the name of the dataset.  I don't think this would be the only problem because under ADO.Net Datasets in a new report, I still get "No items found...."

Are the formats not different somehow?

Is there any significance to the different icons I mentioned before?

Thanks
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 350 total points
Comment Utility
I do not use Typed Dataset so I don't have the "ready-made" datasets. All I can say is that if you follow the schema creation, rename it correctly, you should see it when you create a new report. If you try to add it to an existing report, CR is somewhat buggy and you have to refresh the datasources many times before it can be seen.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:PantoffelSlippers
Comment Utility
Thanks

I'll try one more time...
0
 

Author Comment

by:PantoffelSlippers
Comment Utility
Hi

Any other thoughts on this?
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
As I already told, I do not use typed dataset with CR
0
 
LVL 1

Assisted Solution

by:summititsolutions
summititsolutions earned 50 total points
Comment Utility
Once you've created the second .xsd and placed is somewhere on your file system, go to the database expert.  Go to Ceate New Connection --> ADO.Net --> Make New Connection.  Browse to the .xsd file and click finish.  A new folder named "NewDataSet" will be created  under (Create New Connection --> ADO.Net) and  in this folder you should see your dataset.
0
 

Author Closing Comment

by:PantoffelSlippers
Comment Utility
Thanks - I still can't get it to work but there is no time left for this.  I'm finding workarounds now.  The problem is most probably with me and not with your solutions suggestions.  Thanks again.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now