473,574 Members | 3,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting parameters on Crystal Report - Urgent

Hi,

I've got a Crystal Report that gets some data from a stored procedure and I
need to set some params of the proc at runtime.
But no matter what I do, I cannot get the report to eat the params - it
keeps showing an error that the proc needs to have it's params initialized.

Code's something like:

ConnectionInfo ci = new ConnectionInfo( );
ci.ServerName = sqlServer;
ci.DatabaseName = sqlDatabase;
ci.UserID = sqlUser;
ci.Password = sqlPassword;

TableLogOnInfo ti = new TableLogOnInfo( );
ti.ConnectionIn fo = ci;

ReportDocument doc = new ReportDocument( );
doc.Load(report Doc); // Some .rpt file
doc.SetDatabase Logon(sqlUser, sqlPassword);

foreach(Table t in doc.Database.Ta bles)
{
t.ApplyLogOnInf o(ti);
if(!t.TestConne ctivity())
{
return -2;
}
}

ParameterFieldD efinitions pfds = doc.DataDefinit ion.ParameterFi elds;
for(int i = 0; i < 3; i++)
{
string name = "";
string value = "";

switch(i)
{
case 0:
name = "@ItemName" ;
value = "ZZZZZ";
break;
case 1:
name = "@ItemCount ";
value = "10";
break;
case 2:
name = "@ItemOptio n";
value = "0";
break;
}

ParameterDiscre teValue pdv = new ParameterDiscre teValue();
pdv.Value = value;

ParameterValues pvs = new ParameterValues ();
pvs.Add(pdv);

ParameterFieldD efinition pfd = pfds[name];
pfd.ApplyCurren tValues(pvs);
}

_reportViewer.R eportSource = doc;

Running through the params before setting the report on the viewer tells me
that all params has a current value!
Where am I getting wrong, or what am I missing to do ??

Thanks in advance

Soren

Feb 6 '06 #1
1 4244
Hi,
I always use ReportDocument. SetParameterVal ue( "ParameterN ame" ,
par_value );

I have never have any problem with it.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Soren S. Jorgensen" <no****@nodomai n.com> wrote in message
news:ON******** ******@TK2MSFTN GP11.phx.gbl...
Hi,

I've got a Crystal Report that gets some data from a stored procedure and
I need to set some params of the proc at runtime.
But no matter what I do, I cannot get the report to eat the params - it
keeps showing an error that the proc needs to have it's params
initialized.

Code's something like:

ConnectionInfo ci = new ConnectionInfo( );
ci.ServerName = sqlServer;
ci.DatabaseName = sqlDatabase;
ci.UserID = sqlUser;
ci.Password = sqlPassword;

TableLogOnInfo ti = new TableLogOnInfo( );
ti.ConnectionIn fo = ci;

ReportDocument doc = new ReportDocument( );
doc.Load(report Doc); // Some .rpt file
doc.SetDatabase Logon(sqlUser, sqlPassword);

foreach(Table t in doc.Database.Ta bles)
{
t.ApplyLogOnInf o(ti);
if(!t.TestConne ctivity())
{
return -2;
}
}

ParameterFieldD efinitions pfds = doc.DataDefinit ion.ParameterFi elds;
for(int i = 0; i < 3; i++)
{
string name = "";
string value = "";

switch(i)
{
case 0:
name = "@ItemName" ;
value = "ZZZZZ";
break;
case 1:
name = "@ItemCount ";
value = "10";
break;
case 2:
name = "@ItemOptio n";
value = "0";
break;
}

ParameterDiscre teValue pdv = new ParameterDiscre teValue();
pdv.Value = value;

ParameterValues pvs = new ParameterValues ();
pvs.Add(pdv);

ParameterFieldD efinition pfd = pfds[name];
pfd.ApplyCurren tValues(pvs);
}

_reportViewer.R eportSource = doc;

Running through the params before setting the report on the viewer tells
me that all params has a current value!
Where am I getting wrong, or what am I missing to do ??

Thanks in advance

Soren

Feb 6 '06 #2

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

Similar topics

0
1203
by: murl | last post by:
I have created a crystal report using crystal9.0, that is linked to a stored procedure in sql2k which requires 2 parameters to be met, a beggining date(smalldatetime) and a endingdate(smalldatetime). In crystal the report works fine after the parameters are met, but when loading the report into my c# app using the crystal report viewer, it...
0
1504
by: murl | last post by:
I have built a crystal report using crystal9.0 that is linked to a stored procedure built in sql2k, which requires 2 parameters beginningdate(smalldatetime),and endingdate(smalldatetime). When the parameters are met in crystal the report shows up correctly with no problems, but when the report is displayed using the crsyatal report viewer in...
0
4891
by: Craig Faulkner | last post by:
I have been fighting through my first crystal report in VS2003.NET and have made some headway. Here is what I've done: 1. Created a crystal report in VS2003 from a SQL stored procedure with parameters through the GUI. 2. Finally got past the logon failure error to display the report using the viewer. I assume that default parameters are...
0
8723
by: stephan | last post by:
I know that this has been beaten to death but I can't seem to resolve my issues (I have 2 of them). I have created a class that exposes a public method which returns a datatable as a datasource for a Crystal Report. The method has a single argument which represents a parameter required by the Stored Procedure. When I generate the report...
2
2711
by: Chris | last post by:
Hi, I'm new to ASP.Net and Crystal but I've been playing with some samples and have run into a problem. If I put all my code into the Page_Init sub of a single form and run that form, the Crystal report runs fine. Now i am trying to create another web form where I can input parameters, hit submit and have those parameters passed to the...
10
2330
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, Obtaining Data Based Upon Multiple Selections From a ListBox... I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual Studio Webform. I wish obtain various records from My_Store_Procedure
3
5233
by: Diggler | last post by:
I was working on a report that is populated with three different tables in a strongly-typed dataset. The tables are populated from custom objects rather than directly from SQL Server. I loop through the objects and add the rows one at a time. I then push the dataset to the Crystal Report. The report worked fine, until this morning. I...
3
2390
by: lodatokab | last post by:
I'm have problem to run crystal report (VS 2005) on my computer with Windows 2000 Server. I run the solution in my dev envroiment (Windows XP) and no problems. When I try to run in on IIS 5.0 on Windows 2000 Server I got the following error: Compiler Error Message: CS0433: The type 'CrystalDecisions.Shared.ExportOptions' exists in both ...
3
1810
by: GaryDean | last post by:
This is really a licence question.... I want to deploy the version of Crystal Reports that comes with Visual Studio 2005 to a production server. Is there another license charge if the I'm licensed on the production server to run Visual Studio? -- Regards, Gary Blakely
0
7841
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8100
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7856
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6509
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5651
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3773
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1099
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.