Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-20
10
Medium Priority
?
1,251 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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