Solved

Feeding Crystal Reports with a dataset from .Net

Posted on 2009-05-03
10
944 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 70

Accepted Solution

by:
Éric Moreau earned 350 total points
ID: 24290135
>>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
ID: 24290208
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 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 350 total points
ID: 24290382
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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:PantoffelSlippers
ID: 24290439
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 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 350 total points
ID: 24291310
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
 

Author Comment

by:PantoffelSlippers
ID: 24296354
Thanks

I'll try one more time...
0
 

Author Comment

by:PantoffelSlippers
ID: 24512744
Hi

Any other thoughts on this?
0
 
LVL 70

Expert Comment

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

Assisted Solution

by:summititsolutions
summititsolutions earned 50 total points
ID: 24652499
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
ID: 31577330
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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