473,387 Members | 1,574 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,387 software developers and data experts.

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.ConnectionInfo = ci;

ReportDocument doc = new ReportDocument();
doc.Load(reportDoc); // Some .rpt file
doc.SetDatabaseLogon(sqlUser, sqlPassword);

foreach(Table t in doc.Database.Tables)
{
t.ApplyLogOnInfo(ti);
if(!t.TestConnectivity())
{
return -2;
}
}

ParameterFieldDefinitions pfds = doc.DataDefinition.ParameterFields;
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 = "@ItemOption";
value = "0";
break;
}

ParameterDiscreteValue pdv = new ParameterDiscreteValue();
pdv.Value = value;

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

ParameterFieldDefinition pfd = pfds[name];
pfd.ApplyCurrentValues(pvs);
}

_reportViewer.ReportSource = 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 4234
Hi,
I always use ReportDocument.SetParameterValue( "ParameterName" ,
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****@nodomain.com> wrote in message
news:ON**************@TK2MSFTNGP11.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.ConnectionInfo = ci;

ReportDocument doc = new ReportDocument();
doc.Load(reportDoc); // Some .rpt file
doc.SetDatabaseLogon(sqlUser, sqlPassword);

foreach(Table t in doc.Database.Tables)
{
t.ApplyLogOnInfo(ti);
if(!t.TestConnectivity())
{
return -2;
}
}

ParameterFieldDefinitions pfds = doc.DataDefinition.ParameterFields;
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 = "@ItemOption";
value = "0";
break;
}

ParameterDiscreteValue pdv = new ParameterDiscreteValue();
pdv.Value = value;

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

ParameterFieldDefinition pfd = pfds[name];
pfd.ApplyCurrentValues(pvs);
}

_reportViewer.ReportSource = 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
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...
0
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...
0
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...
0
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...
2
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...
10
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...
3
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...
3
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...
3
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...

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.