473,756 Members | 7,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crystal Report from an XML Webservice

I've been stuck on a problem now for ages and i'm about ready to pack my
project in because of it lol.

OK here is my scenario.

I have an existing Crystal Report, which I have added to my solution and
published it as a webservice. This report takes it data from an SQL server on
another machine.

The user will have a windows form in a little app i'm writing where it has a
web reference to this report... it will show the report from this Web Service
in the crystal report view control.

I set the report datasource to this web service... however I keep getting
the database logon screen whenever I run the report... if I enter the correct
password it runs fine... but my problem is I dont want this sodding box to
come up all the time!

Ive seen examples of other users problems where they are to set the logon
details for every table but I cannot seem to do this myself as I cant get to
the actual crystal report object from the web service to change the database
table logon bits.

Am I making sense here? Someone please help ths is really sapping my will to
live...

Thanks in advance.

FeveZ
Nov 21 '05 #1
3 9193
Can somebody please shed some light on this as to what im doing wrong?

None of my posts ever get answered :-(

Thanks :-)
Fev
Nov 21 '05 #2
FeveZ,

You can easily stream your report as a PDF straight to the browser, too.
Looks much
more professional than the ugly crystal control on the screen. Here's how to
do what you want (in a nutshell):

1) In your webservice, set your report to get its data from a dataset
2) Have your data layer retrieve the report data in the form of a DataSet
3) Set the reports DataSource (.SetDataSource ) to the DataSet in 3)
4) Export the report to a stream (ExportToStream ), and convert it to a array
of bytes
5) Return the byte array to the calling web page, which can
Response.Binary Write it to the client browser
6) Wipe hands on pants and repeat!

Here's sample code:
yada yada yada: it's always nice to see the USINGS!!
using System;
using System.Componen tModel;
using System.Configur ation;
using System.Data;
using System.Diagnost ics;
using System.Web;
using System.Web.Serv ices;

using Microsoft.Appli cationBlocks.Ex ceptionManageme nt;

using CrystalDecision s.CrystalReport s.Engine;
using CrystalDecision s.Shared;

[WebMethod]
public byte[] GetDataForDTRep ort(int fiscalYearId,in t programId,int
languageId)
{
// Declaration section
ReportDs report = new ReportDs(); //our data service
DataSet reportData = new DataSet();
System.IO.Strea m dataStream;
byte[] pdfReport = new byte[1];
ExportRequestCo ntext requestCtx = new ExportRequestCo ntext();

// Create an instance of your report class
DTReport repDoc = new DTReport();
bool dataReturned = true;

try
{
// Validation section
// Call the data services for the report
reportData =
report.GetDataF orDTReport(fisc alYearId,progra mId,languageId) ;

//If tables are returned
if(reportData.T ables.Count > 0)
{
//If at least one table has no rows
foreach(DataTab le table in reportData.Tabl es)
{
if(table.Rows.C ount == 0)
{
dataReturned = false;
break;
}
}
if(dataReturned )
{
// Set the data source for the report
repDoc.SetDataS ource(reportDat a);
repDoc.ExportOp tions.ExportFor matType =
ExportFormatTyp e.PortableDocFo rmat;
repDoc.ExportOp tions.FormatOpt ions = new PdfRtfWordForma tOptions();
requestCtx.Expo rtInfo = repDoc.ExportOp tions;
dataStream = repDoc.FormatEn gine.ExportToSt ream(requestCtx );

// Convert the data stream with the pdf report into an array
pdfReport = new byte[dataStream.Leng th];
dataStream.Read (pdfReport,0,(i nt)dataStream.L ength);
dataStream.Clos e();
}
}
return pdfReport;
}
catch(Exception ex)
{
// Wrap exception and rethrow
throw new BaseApplication Exception("Web Service Exception", ex);
}
finally
{
// Cleanup code
reportData = null;
dataStream = null;
pdfReport = null;
}
}
--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never
comes back.

"FeveZ" <Fe***@discussi ons.microsoft.c om> wrote in message
news:11******** *************** ***********@mic rosoft.com...
I've been stuck on a problem now for ages and i'm about ready to pack my
project in because of it lol.

OK here is my scenario.

I have an existing Crystal Report, which I have added to my solution and
published it as a webservice. This report takes it data from an SQL server on another machine.

The user will have a windows form in a little app i'm writing where it has a web reference to this report... it will show the report from this Web Service in the crystal report view control.

I set the report datasource to this web service... however I keep getting
the database logon screen whenever I run the report... if I enter the correct password it runs fine... but my problem is I dont want this sodding box to
come up all the time!

Ive seen examples of other users problems where they are to set the logon
details for every table but I cannot seem to do this myself as I cant get to the actual crystal report object from the web service to change the database table logon bits.

Am I making sense here? Someone please help ths is really sapping my will to live...

Thanks in advance.

FeveZ

Nov 21 '05 #3
Sweet thanks... Cant test it right now because im away from my dev kit :-D

I'll let you know how it goes :D

Thanks again :-)

Fev
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2514
by: Mike | last post by:
Anyone have an example on how to stream a crystal report in pdf format from a webservice? Thanks in advance. Mike
0
1325
by: FeveZ | last post by:
I want to call a general purpose webservice that will return a dataset with the required data for a given report. Each '.rpt' file is stored on a users PC, where I want to pass a ReportID to it and display its data in a crystal report viewer control on a windows form. Each of the different reports can have lots of joins to other tables... wether this has any relevance i dont know.
5
3084
by: Ron | last post by:
I have a bunch of Crystal Reports (v9) published as WebServices and use a ReportViewer to display the reports on the ASPNET page. Everytime we move the reports from dev to production we have to open the reports and manually change the datasouce to the production database. Is there a way to set the datasouce on the webserviced reports dynamically? (A datasource property or something?) cant seem to find anything. Thanks!
0
923
by: agustianhans | last post by:
Hi, friend I use Crystal Report 8.5 in my application (.NET 2002). I have 2 application : 1. ASP WebService Application. 2. Windows Application. I use Crystal Report 8.5 as Report WebService (in ASP WebService Application) and i access the report from Windows Application.
0
1134
by: Li Pang | last post by:
Hi, The following codes are used to define a web method which returns a crystal report document in a file named "Service1.asmx". When I right-click on "View in Browser" I got the error --------------------------------------------------------------------------------- Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface. Description: An unhandled exception occurred...
0
1587
by: Darrell | last post by:
I am using VS 2005 Beta 2 on XP Pro. I have created a WebService with an "empty" Crystal Report. The only thing in this report is a text element saying "Hello World!". If I run the WebService via debugging on the APS.NET Development Server, all is fine. When I try this via IIS 5.1, I get the exception "Load Report Failed". I believe that I have set folder permission rather open to see if this gets rid of the problem but still no go. Is...
3
3571
by: David P. Donahue | last post by:
Maybe this is an easy thing to do, but I'm just not seeing how it's done (or at least how it's done properly). I have a web service running on a remote machine which returns a DataSet. I can easily write an xsd file to define that DataSet, if need be. Now, on a local Windows Forms application, I need to have a CrystalReportViewer open up a Crystal Report which needs to get its data from that Web Service. How would this be done? It's...
0
1534
by: TMesh | last post by:
Hello Is it possible to return a Crystal ReportDocument from a WebService? I keep getting the following error: Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---System.InvalidOperationException: There was an error generating the XML document. ---System.InvalidOperationException: The type CrystalDecisions.CrystalReports.Engine.ReportDocument was not expected. Use
7
2511
by: eschneider | last post by:
I have a webservice which every time I build it keeps adding Crystal references into the web.config? <add assembly="CrystalDecisions.Shared, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> And No, I do not have any references to crystal when I look at project
0
9287
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.