Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2008, 03:36 AM
Registered User
 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to send the report to printer

hi,:)

I'm new to c#.net. i need ur help.
How to send the report file to the printer without showing the report file

i had tried with this code, but shows error.

string path = Application.StartupPath;
int index = path.LastIndexOf("\\bin");
path = path.Substring(0, index + 1);

Reports.PurchaseOrder _vendorPO = new PrjAccounts.Reports.PurchaseOrder();
_vendorPO.SetDataSource(_getDT);

ReportClass crReportDocument = new ReportClass();
crReportDocument.FileName = path + @"Reports\PurchaseOrder.rpt";

crReportDocument.PrintToPrinter(1, true, 1, 1);
//error in this line its not getting the filename properly
//error in file:c:\document\temp\PurchaseOrder.rpt
//:unable to connect: incorrect log on parameters.


Thanks in advance
N.Sheik Dawood
 
Old July 17th, 2008, 04:22 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

OK, two things. Firstly - you should separate your two bits of code. if you set crReportDocument.FileName to a fixed string, does it still work.

Secondly, the error "Unable to connect: incorrect log on parameters" doesn't sound like the error is to do with the filename to me, sounds more like a database error.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 18th, 2008, 05:35 AM
Registered User
 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi sam,
thanks for replying me.
i think its works. the string path is dynamically created path from Application.StartupPath; and remaining string is where the crystal report file resides.

and its not a database error, since its shows the error message after executing the line
crReportDocument.PrintToPrinter(1, true, 1, 1);

please reply me asap so that i can proceed my work.


Thanks in advance
N.Sheik Dawood
 
Old July 18th, 2008, 05:53 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I have no idea - you say everything is ok, but it doesn't work - something must be wrong, either the file path (in which case I would expect an error such as "File not found") or the connection to the database is failing.

I still believe its more likely to be a database connection error, but have no way of proving or diproving that based on the information you have provided.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 18th, 2008, 06:02 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

A google comes up with http://forums.msdn.microsoft.com/en-...-3ead3b803a4d/ which looks pretty comprehensive.. Several different variations on the problem and all solved.

If you are EVER stuck on an error, a quote search on Google should be your first port of call...

Rob
http://cantgrokwontgrok.blogspot.com
 
Old July 24th, 2008, 02:07 AM
Registered User
 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks sam and rob:), spending your valuable time for replying me.:D

Thanks in advance
N.Sheik Dawood
 
Old July 24th, 2008, 02:11 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

No problem :) Did you get the issue resolved?

Rob
http://cantgrokwontgrok.blogspot.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
This report uses invalid printer - Naren mnr555 Crystal Reports 6 December 29th, 2014 01:08 AM
how to send escape sequence to printer ergoktas C# 0 November 28th, 2006 04:36 AM
Report getting Printer info error PamS Access 2 October 29th, 2003 04:38 PM
how to send numerous pages to the printer lcsgeek Classic ASP Basics 1 October 4th, 2003 10:36 AM
To send reports direct to the printer magesh_bala Classic ASP Professional 2 September 4th, 2003 04:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.