473,503 Members | 1,768 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 9166
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.BinaryWrite 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.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;

using Microsoft.ApplicationBlocks.ExceptionManagement;

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

[WebMethod]
public byte[] GetDataForDTReport(int fiscalYearId,int programId,int
languageId)
{
// Declaration section
ReportDs report = new ReportDs(); //our data service
DataSet reportData = new DataSet();
System.IO.Stream dataStream;
byte[] pdfReport = new byte[1];
ExportRequestContext requestCtx = new ExportRequestContext();

// 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.GetDataForDTReport(fiscalYearId,programId,l anguageId);

//If tables are returned
if(reportData.Tables.Count > 0)
{
//If at least one table has no rows
foreach(DataTable table in reportData.Tables)
{
if(table.Rows.Count == 0)
{
dataReturned = false;
break;
}
}
if(dataReturned)
{
// Set the data source for the report
repDoc.SetDataSource(reportData);
repDoc.ExportOptions.ExportFormatType =
ExportFormatType.PortableDocFormat;
repDoc.ExportOptions.FormatOptions = new PdfRtfWordFormatOptions();
requestCtx.ExportInfo = repDoc.ExportOptions;
dataStream = repDoc.FormatEngine.ExportToStream(requestCtx);

// Convert the data stream with the pdf report into an array
pdfReport = new byte[dataStream.Length];
dataStream.Read(pdfReport,0,(int)dataStream.Length );
dataStream.Close();
}
}
return pdfReport;
}
catch(Exception ex)
{
// Wrap exception and rethrow
throw new BaseApplicationException("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***@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.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
2488
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
1308
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...
5
3063
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...
0
911
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...
0
1122
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...
0
1568
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...
3
3559
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...
0
1518
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...
7
2497
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,...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
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...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6984
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...
0
7453
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...
0
5576
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,...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
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 ...

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.