crystal reports in c# / disable parameter prompt
Hi everyone,
is there a way to disable the parameter prompt of the crystal report viewer in c# (2005 beta2)?
I've got a simple report viewer, which doesn't have the smart tag to disable the parameter prompt as apparently the viewer for asp.net does, I'm loading a simple report with a parameter at runtime where I also set the parameter in the code, but still it'll prompt me for that anoying parameter and use the one from the prompt!!
I didn't find any option in there (at least not in intelliSense...) to disable it...
Any help much appreciated... thanks very much!
Vince
[592 byte] By [
Vince206] at [2007-12-16]
Don't listen to keith he points everyone at that lame sample, even though he has been told multiple time that IT DOESN'T WORK! He has been given exact replications of the code and shown that it doesn't work. I'm beginning to wonder if he is a person at all or just some type of bot that watches this newsgroup and spits out a link to those samples at infrequent intervals.
CR for VS2005 is broke, they released an update for CRXI (which you have to pay for) but haven't fixed CR for VS 2005. Guess their revenue stream is low and they lack any respect for any support for a product that was included with VS 2005.
Just curious - did you ever get this resolved? I am having the same issue but can find no fix. I have tried using the sample Business Objects code but It did not fix the issue
Thanks,
Tom
Hey Tom,
sorry, don't even remember what that was about... so apparently I got it resolved somehow... actually I think I might have used MS Reporting Services instead... was getting annoyed with Crystal anyway.
Sorry can't tell you more, honestly don't remember what I needed it for... used some kind of workaround.
Cheers
Andy
Been there, tried that, Doing it tomorrow ;). Well managed to find the solution for this problem. The code is as following.
discreteVal.Value = m_ReportParameterValue;
paramField.CurrentValues.Clear();
paramField.CurrentValues.Add (discreteVal);
paramField.HasCurrentValue =
true; paramFields.Add(paramField);
crvReport.RefreshReport();
The magic is in the setting the ParamField.HasCurrentValue = True (and in my case I needed to Refresh the report. Did not know why it was not enough just to set the param to true.)
Well Enjoy.
Does this solve the problem with parameter prompting for linked parameters on subreports?
I haven';t tried implementing your code yet. I did notice that RefreshReport is an event on the reportdocument not a method.
OK, I was able to get this to work for linked parameters which had the same name as the top level report parameters which were being passed in to the report request.
I did this by populating all values for all parameters with the same name as the top level report parameters. Unfortunately this does not cover linked parameters which have a different name than the top level report parameter.
Do you know any way of determining from the ReportDocument what the mapping is from top level parameters to subreport parameters?
It does seem that this is headed in the right direction since I am not prompted for all subreport parameters, just the ones that are not the same name as the parameter to which they are linked. I just need to find the mapping so we don't have to change the reports/ or change the way that reports are being initiated.
I just wish BO would fix it so this isn't necessary, it should be populating the linked parameters without having to explicitly set them when the connection context is changed.
OK, here is what I did.
Hashtable ht = new Hashtable(new CaseInsensitiveHashCodeProvider(), new CaseInsensitiveComparer()); repDoc.SetParameterValue(0, 91334); repDoc.SetParameterValue(1, 0); repDoc.SetParameterValue(2, 1033); repDoc.SetParameterValue(3, 14988); ht.Add(repDoc.ParameterFields[0].Name, repDoc.DataDefinition.ParameterFields[0].CurrentValues[0]); ht.Add(repDoc.ParameterFields[1].Name, repDoc.DataDefinition.ParameterFields[1].CurrentValues[0]); ht.Add(repDoc.ParameterFields[2].Name, repDoc.DataDefinition.ParameterFields[2].CurrentValues[0]); ht.Add(repDoc.ParameterFields[3].Name, repDoc.DataDefinition.ParameterFields[3].CurrentValues[0]);
Then after setting the conninfo in the report and subreports. (I had to change the reportparameter names to match the linked subreport parameter names)
foreach (ParameterField pf in repDoc.ParameterFields) { if (ht.ContainsKey(pf.Name)) { pf.CurrentValues.Clear(); pf.CurrentValues.Add((ParameterValue)ht[pf.Name]); pf.HasCurrentValue = true; Console.WriteLine(pf.Name + " = " + ((ParameterDiscreteValue)ht[pf.Name]).Value.ToString()); } }
Looks like this may be workable,although it requires going through all (100+) reports and modifying the parameters. Thanks for the pointer, Bad Tooth!
OK, still working on it.
I get internittant errors when displaying the report in the viewer 'operation illegal on linked parameter'
Seems like in the Hashtable iteration if i check for not only the existance of the parameter name in the hashtable but also whther the parameter belongs to a subreport (&& pf.ReportName.Length == 0) it stops having the errors when the report is displayed. So it must be cascading the value for the linked parameter, it must just not be triggering the cascade property set when using the SetParameterValue method on the reportdoc.
OK, final observations.
I think the difference in the setparametervalue between 9.0 and 10.2 is that it triggeres a validatedatbase or a refresh when you do it in 10.2. This would explain the loss of values and the necessity of resetting the prametervalues directly.
Just a guess. But I did revert back to the original report and did not have to rename the parameters after making sure that I was only setting the top level parameters after the conninfo was set on all tables in the report and subreport.
If anyone is interested, I'll post the full code.
Let me say that the patch works fine. The prompt' window for parameters values is not displayed now. A partner say me that this hotfix is not necessary, but... if this is not applied the window is shown.
TESTED!
Hi Joe
I am getting the same parameter prompt of the crystal report viewer in (MS visual studio 2005 .Net Framework 2.0)
My rpt containes the subreports having the same parameter name as top level main report & I providing the parameter value at runtime. Sometimes it works fine, but manytimes it asks for Parameter and that anoying Parameter Prompt pops up.
Can post the code to resolve this problem?
Thanks
See the link in my previous message to download the hotfix. I never found a completely reliable way to fix this solely in code.