472,371 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

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 9047
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
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
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
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
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
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
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
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
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
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,...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.