471,348 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 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 4158
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Adis | last post: by
3 posts views Thread by Diggler | last post: by
3 posts views Thread by GaryDean | last post: by
1 post views Thread by Ronak mishra | last post: by

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.