Solved

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

Posted on 2010-08-20
10
1,230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
10 Comments
 
LVL 101

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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

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 101

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

734 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