Solved

Set Crystal Report DataSource to Dynamic In-Memory Only .NET DataSet

Posted on 2010-08-20
10
1,203 Views
Last Modified: 2012-05-10
Hello,

I created an in-memory, runtime only .NET DataSet with four tables and generated an XMLSchema file that I used to create a Crystal Report (.rpt).  Everything I've have read so far in the Crystal Reports 11 documentation indicates I must connect to a physical database before I can set the ReportDocument DataSource.  

1.  Is it possible for me to connect to the in-memory DataSet if it is not connected to an external datasource?  If yes, how can I do this with the ReportDocument class?

2.  Does the xsd file need to be located in the application directory?

This is what I would like to do...the code below bombs on the call to SetDataSource(DataSet) with the message
ex = {"The data source object is invalid."}

ReportDocument drillDownCrystalReport = new ReportDocument();
string applicationPath;
applicationPath = System.AppDomain.CurrentDomain.BaseDirectory;
string reportFilename = drilldownreport.ReportFilename;
drillDownCrystalReport.Load(applicationPath + reportFilename);
drillDownCrystalReport.SetDataSource(reportDataSet);

Thank you.
0
Comment
Question by:MicheleDunham
  • 5
  • 2
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 33490435
0
 

Author Comment

by:MicheleDunham
ID: 33503476
Hello,

I am following the example in the article above.  I created a new "report" project within my web service project.  I dragged the xml schema file into the new "Report" project and that works fine.  However, when I step through adding a report to the project (figure 4) the schema is not available under "Project Data - ADO.NET Datasets."  I don't see that I have deviated in any way from the steps in the article.

Please see attached screenshot.

Thanks,
Michele
VS2005CrystalReportIntegration.pdf
0
 

Author Comment

by:MicheleDunham
ID: 33503616
I have an update to the problem I documented above...

Initially I dragged the XML Schema file from Windows Explorer into the Project "Report."  I went back and "Added Existing Item" to the Project and now it shows up in the Project Data...ADO.NET Datasets.
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:MicheleDunham
ID: 33504561
I am now through creating a report inside VS 2005 and this is where my code differs.  I am attempting to create this report inside a web service.  I have followed all of the steps up to the Testing Your Report section.  My code uses a ReportDocument; not a CrystalReportViewer.  When I attempt to SetDataSource I get the same error as before...

ex = {"The data source object is invalid."}

Perhaps I need to build the xsd and rpt inside the web service project instead of creating a separate "Reports" project inside the web service project?
0
 

Author Comment

by:MicheleDunham
ID: 33505504
Although initially promising the solution posted above doesn't work with a .NET web service in Visual Studio 2005.   At this point I am entertaining alternative solutions....utilmately I would like to convert the "report" to a pdf and then a byte stream to return to the calling program...here is how the code would have worked with Crystal.

MemoryStream oStream;
oStream = (MemoryStream)drillDownCrystalReport.ExportToStream
                 (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Byte[] reportPDFByteArray = oStream.ToArray();
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 33506434
I don't know how to handle a Crystal Report inside a web service.

mlmcc
0
 
LVL 11

Accepted Solution

by:
tickett earned 500 total points
ID: 33529217
Hi, i haven't used datasets with Crystal in vb.NET but i have sucessfully used a web service in conjunction with the report document.

Can you try "starting simple" i.e. use a report with a connection to a "ole db" data source and then we can hopefully pin-point the problem to the dataset.

Alternatively- try create a windows applications with the crystal report viewer and your dataset and go from there.

L
0
 

Author Closing Comment

by:MicheleDunham
ID: 33532431
I discovered a mistake in my code and you are correct that a Crystal Report can work inside a .NET web service exactly as I set out to do...with a dynamic in-memory .NET dataset.  All that is necessary is to create an XSD; drag it over to the .NET solution in Solution Explorer.  Add A New (Crystal Report) Item to the solution and then step through the Standard Report wizard.  The XSD is found under Create New Connection -> Database Files.  Build the report directly in the web service.  Use the code detailed above to connect the in-memory DataSet to the Crystal Report and then export a PDF byte stream.  It works perfectly.

0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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