Solved

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

Posted on 2010-08-20
10
1,191 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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 …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

11 Experts available now in Live!

Get 1:1 Help Now