Solved

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

Posted on 2010-08-20
10
1,173 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Round a string to two digits 12 24
index Out OF Range Exception error 4 32
Closing all open child forms. 4 24
Open a word document 23 18
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 …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

19 Experts available now in Live!

Get 1:1 Help Now