473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem with Crystal Report

Hi, i have a simple report with 1 parameter and i want to send it to
the printer without use the crystalreportviewer but it shows me an
exception "Parameter value is needed",maybe the problem can be in the
way to pass it the parameter.
CrystalReport1 cr = null;
try
{
cr = new CrystalReport1();
cr.FileName="C:\\Proyectos .Net\\crystal\\CrystalReport1.rpt";
cr.Load();

cr.SetParameterValue("person","000002");
cr.PrintOptions.PrinterName = "\\\\ACTEA3\\lj4000";

cr.Refresh();
cr.PrintToPrinter(1,false,0,0);
}

Any idea would be apreciated.

Nov 17 '05 #1
7 5745
Hi,

IIRC you do not need to load it from File, it's embedded as a resource and
when you instantiate it its load

if you just show it in the screen does it work ok?
do you have a default printer set?, can you just try with it instead of
using a network printer?

the parameter seems to be ok,

If that do not work, what if you use a crystalreportviewer but do not show
it, you load the report, etc but then just print it
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Victor" <vi************@actea.es> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi, i have a simple report with 1 parameter and i want to send it to
the printer without use the crystalreportviewer but it shows me an
exception "Parameter value is needed",maybe the problem can be in the
way to pass it the parameter.
CrystalReport1 cr = null;
try
{
cr = new CrystalReport1();
cr.FileName="C:\\Proyectos .Net\\crystal\\CrystalReport1.rpt";
cr.Load();

cr.SetParameterValue("person","000002");
cr.PrintOptions.PrinterName = "\\\\ACTEA3\\lj4000";

cr.Refresh();
cr.PrintToPrinter(1,false,0,0);
}

Any idea would be apreciated.

Nov 17 '05 #2
Hi,

IIRC you do not need to load it from File, it's embedded as a resource and
when you instantiate it its load

if you just show it in the screen does it work ok?
do you have a default printer set?, can you just try with it instead of
using a network printer?

the parameter seems to be ok,

If that do not work, what if you use a crystalreportviewer but do not show
it, you load the report, etc but then just print it
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Victor" <vi************@actea.es> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi, i have a simple report with 1 parameter and i want to send it to
the printer without use the crystalreportviewer but it shows me an
exception "Parameter value is needed",maybe the problem can be in the
way to pass it the parameter.
CrystalReport1 cr = null;
try
{
cr = new CrystalReport1();
cr.FileName="C:\\Proyectos .Net\\crystal\\CrystalReport1.rpt";
cr.Load();

cr.SetParameterValue("person","000002");
cr.PrintOptions.PrinterName = "\\\\ACTEA3\\lj4000";

cr.Refresh();
cr.PrintToPrinter(1,false,0,0);
}

Any idea would be apreciated.

Nov 17 '05 #3
Hi, i tested to show it in the screen and it worked ok,i tested to use
the crystalreportviewer and the parameters worked ok but the problem
was that i can't or i don't find how to specify the printer i want to
use in the crystalreportviewer component, it printed by default printer
on the computer.

Nov 17 '05 #4
Hi, i tested to show it in the screen and it worked ok,i tested to use
the crystalreportviewer and the parameters worked ok but the problem
was that i can't or i don't find how to specify the printer i want to
use in the crystalreportviewer component, it printed by default printer
on the computer.

Nov 17 '05 #5
I have found the solution, here is the code, thanks for the help.

CrystalReport1 cr = null;
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;

try
{
cr = new CrystalReport1();
cr.FileName = "C:\\Proyectos
..Net\\granitos\\crystal\\CrystalReport1.rpt";

//Get the collection of parameters from the report
crParameterFieldDefinitions = cr.DataDefinition.ParameterFields;

//Access the specified parameter from the collection
crParameterFieldDefinition = crParameterFieldDefinitions["persona"];

//Get the current values from the parameter field. At this point
//there are zero values set.
crParameterValues = crParameterFieldDefinition.CurrentValues;

//Set the current values for the parameter field
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "000002"; //1st current value

//Add the first current value for the parameter field
crParameterValues.Add(crParameterDiscreteValue);

//All current parameter values must be applied for the parameter field.
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues);

cr.PrintOptions.PrinterName = "\\\\ACTEA3\\lj4000";
cr.PrintToPrinter(1,false,0,0);
}

Nov 17 '05 #6
I have found the solution, here is the code, thanks for the help.

CrystalReport1 cr = null;
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;

try
{
cr = new CrystalReport1();
cr.FileName = "C:\\Proyectos
..Net\\granitos\\crystal\\CrystalReport1.rpt";

//Get the collection of parameters from the report
crParameterFieldDefinitions = cr.DataDefinition.ParameterFields;

//Access the specified parameter from the collection
crParameterFieldDefinition = crParameterFieldDefinitions["persona"];

//Get the current values from the parameter field. At this point
//there are zero values set.
crParameterValues = crParameterFieldDefinition.CurrentValues;

//Set the current values for the parameter field
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "000002"; //1st current value

//Add the first current value for the parameter field
crParameterValues.Add(crParameterDiscreteValue);

//All current parameter values must be applied for the parameter field.
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues);

cr.PrintOptions.PrinterName = "\\\\ACTEA3\\lj4000";
cr.PrintToPrinter(1,false,0,0);
}

Nov 17 '05 #7
Hi Victor,

Ok, good to know

Cuidate ;)
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Victor" <vi************@actea.es> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have found the solution, here is the code, thanks for the help.

CrystalReport1 cr = null;
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;

try
{
cr = new CrystalReport1();
cr.FileName = "C:\\Proyectos
.Net\\granitos\\crystal\\CrystalReport1.rpt";

//Get the collection of parameters from the report
crParameterFieldDefinitions = cr.DataDefinition.ParameterFields;

//Access the specified parameter from the collection
crParameterFieldDefinition = crParameterFieldDefinitions["persona"];

//Get the current values from the parameter field. At this point
//there are zero values set.
crParameterValues = crParameterFieldDefinition.CurrentValues;

//Set the current values for the parameter field
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "000002"; //1st current value

//Add the first current value for the parameter field
crParameterValues.Add(crParameterDiscreteValue);

//All current parameter values must be applied for the parameter field.
crParameterFieldDefinition.ApplyCurrentValues(crPa rameterValues);

cr.PrintOptions.PrinterName = "\\\\ACTEA3\\lj4000";
cr.PrintToPrinter(1,false,0,0);
}

Nov 17 '05 #8

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

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
0
by: Max | last post by:
Hi wise people, Has anyone encountered the Crystal Reports problem I describe below? If so, how did you solve it? It seems that every article posted on google regarding CR and logon problems is...
0
by: Plunaldo | last post by:
Hi All I use a ODBC Connection to Connect to a AS400 System. I created a new DSN in the Windows System. The Databaseaccess is made directly out of the Crystal Report...so the Crystal Report is...
0
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather...
3
by: Milan Todorovic | last post by:
Hello, I need help. I have experience in ASP.NET programming, but this is my first dealing with Crystal Reports. I'm trying to make the most basic report purely for testing purposes: connect to...
3
by: route_coder | last post by:
I am using access database to create a crystal report in VB.NET Everything works fine when I run on my machine. But when I am deploying it other windows machines. It is asking for database server...
0
by: Monali | last post by:
Hi, I created a ASP.NET crystal reports web site in VS 2005. I wanted to display the data in a DataSet in the Crystal Reports viewer control. I am getting the DataSet from another dll. The...
1
by: Sean Chiu | last post by:
Hi all, I have a problem on crystal report xml report service. After I finished a simple report service and tested it in local IIS, it works. However, when publishing it to a production IIS...
1
by: sushanta | last post by:
Dear sir, In details my problem is: What I want to do: Populate data from database in the crystal report with a specific query What I have done: I have decleared a dataset YWStatus.xsd ...
1
by: pintoo | last post by:
Hi, I have 2 sites (Site A, B) running on same windows 2003 server pointing to different home directories. User logs into site A and is shown a.aspx page and user credentials are saved in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
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,...

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.