473,473 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Print Crystal Report Without Viewer

Using VS 2005, CR10, writing in C#.NET.

How do I open a report, change the dataset, and export the results to PDF
from code without any user interaction?
Jul 5 '06 #1
2 8025
Hi,
"Andrew Hayes" <An*********@discussions.microsoft.comwrote in message
news:eb**************@TK2MSFTNGP05.phx.gbl...
Using VS 2005, CR10, writing in C#.NET.

How do I open a report, change the dataset, and export the results to PDF
from code without any user interaction?
Just doing it :)

Instantiate the report, get the dataset, use ReportDocument.SetDataSource(
theDataSet )

Then use ReportToDisk to export it in pdf format
and you are ready :)

Let me know if you need code, but it;s very straighforward.

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jul 5 '06 #2

i have this code :

ReportDocument reportDocument1 = new ReportDocument();
reportDocument1.Load(Request.PhysicalApplicationPa th +
"\\reports\\VBilancio.rpt");

reportDocument1.SetDataSource(dsBil);
string TargetFileName;
FileStream fs;
long FileSize;
ExportOptions oExO;
DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();
TargetFileName = Request.PhysicalApplicationPath + "\\Export\\" +
Session.SessionID + "bilancio.pdf";

oExDo.DiskFileName = TargetFileName;
oExO = reportDocument1.ExportOptions;
oExO.ExportDestinationType = ExportDestinationType.DiskFile;
oExO.ExportFormatType = ExportFormatType.PortableDocFormat;
oExO.DestinationOptions = oExDo;

reportDocument1.PrintOptions.PaperOrientation=Pape rOrientation.Landscape;
reportDocument1.SetParameterValue("data_fine",data 2);
reportDocument1.SetParameterValue("data_ini",data1 );
reportDocument1.Export();
reportDocument1.Close();

Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition",
"attachment;filename=ReportBilancio.pdf;");
fs = new FileStream(TargetFileName, FileMode.Open);
FileSize = fs.Length;

byte[] bBuffer = new byte[(int)(FileSize)];
fs.Read(bBuffer, 0, (int)(FileSize));

fs.Close();
Response.BinaryWrite(bBuffer);
Response.Flush();
Response.Close();

this code was ok with visual studio .net 2003 but with visual studio 2005
dont'work and appears an error similar to this :

error in the motor of the query

the permissions are ok and the the virtual directory is ok

what can he be?

thanks a lot
Micky

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
"Andrew Hayes" <An*********@discussions.microsoft.comwrote in message
news:eb**************@TK2MSFTNGP05.phx.gbl...
Using VS 2005, CR10, writing in C#.NET.

How do I open a report, change the dataset, and export the results to PDF
from code without any user interaction?

Just doing it :)

Instantiate the report, get the dataset, use ReportDocument.SetDataSource(
theDataSet )

Then use ReportToDisk to export it in pdf format
and you are ready :)

Let me know if you need code, but it;s very straighforward.

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Sep 14 '06 #3

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

Similar topics

4
by: Wendy Elizabeth | last post by:
I would like to know how to print a crystal report that was generated in the ..NET framework using a Visual Basic.NET web application and/or a Visual basic.NET windows application. When crystal...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
0
by: Anniech | last post by:
I use VB.NET to integrate with crystal report 9.0 to print a report with custom paper size (using Dot Matrix printer). I have already added a custom paper size in the printer server and set the...
0
by: Chris | last post by:
I have the following situation in a VB.Net App I am working on: 1.)A report created in VS.Net 2003 using the CR.Net component of VS 2003. 2.)The datasource for the report is a Stored Proc in a...
2
by: Rod | last post by:
We've got an old VB6 application which has 9 Crystal Reports it can print. These 9 reports are considered by our users to be in essence one "report", in the sense that they are all related and they...
0
by: John Smith | last post by:
Hello, I am developing a VB.NET 2003 application that will use lots of Crystal Reports. Sometimes the users will preview a report in a Crystal report viewer, and sometimes they will send the...
1
by: Kbalz | last post by:
Having a really hard time finding solid examples on deploying a CR .NET applcation on my intranet. I'll explain what I've done so far, and toward the bottom is where I can't print using the report...
6
by: Simone | last post by:
Hello Here is my issue, I created a crystal report using a data set from my xsd. Then I created a page with the crystal report viewer control and bound the report to it. When I try to view...
0
by: David C. Barber | last post by:
How can I determine if a report in the Crystal Report Viewer on an ASP page has been printed by the user? It's important to know the difference between someone just viewing a report, and actually...
0
by: David C. Barber | last post by:
How can I determine if a report in the Crystal Report Viewer on an ASP page has been printed by the user? It's important to know the difference between someone just viewing a report, and actually...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...
1
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
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.