on ‎2011 Mar 11 3:01 AM
In database i choose stored procedure, parameter field automatically created and then i remove @ in parameter field,
i used three method searched in asp .net, all failed. Error is missing parameter values.
I have also tried to add back @ also failed
Method 1
// First parameter
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"].ToString();
crParameterFieldDefinitions = objRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["Cheque_IssueRecord_Secretary_Review_TT_ID"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
// Second parameter
ParameterFieldDefinitions crParameterFieldDefinitions2;
ParameterFieldDefinition crParameterFieldDefinition2;
ParameterValues crParameterValues2 = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue2 = new ParameterDiscreteValue();
crParameterDiscreteValue2.Value = Request.QueryString["tCOMDB"].ToString();
crParameterFieldDefinitions2 = objRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition2 = crParameterFieldDefinitions2["tCOMDB"];
crParameterValues2 = crParameterFieldDefinition2.CurrentValues;
crParameterValues2.Clear();
crParameterValues2.Add(crParameterDiscreteValue2);
crParameterFieldDefinition2.ApplyCurrentValues(crParameterValues2);Method 2
var value = new ParameterDiscreteValue();
value.Value = Convert.ToInt32(Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"]);
objRpt.ParameterFields["Cheque_IssueRecord_Secretary_Review_TT_ID"].CurrentValues.Add(value);
var value2 = new ParameterDiscreteValue();
value2.Value = Request.QueryString["tCOMDB"];
objRpt.ParameterFields["tCOMDB"].CurrentValues.Add(value2);
Method 3
CrystalReportViewer1.ReportSource = objRpt;
foreach (ParameterField p in CrystalReportViewer1.ParameterFieldInfo)
{
//if (Request.QueryString[p.Name])
//{
var value = Request.QueryString[p.ToString()];
if (p.CurrentValues.Count > 0)
((ParameterDiscreteValue)p.CurrentValues[0]).Value = value;
else
p.CurrentValues.Add(new ParameterDiscreteValue() { Value = value });
//}
}
Methdod4
/
/objRpt.SetParameterValue(0, Convert.ToInt32(Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"]));
//objRpt.SetParameterValue(1, Request.QueryString["tCOMDB"]);
Request clarification before answering.
I solved
objRpt.SetParameterValue(0, Convert.ToInt32(Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"]));
objRpt.SetParameterValue(1, Request.QueryString["tCOMDB"]);
//The viewer's reportsource must be set to a report before any parameter fields can be accessed.
CrystalReportViewer1.ReportSource = objRpt;
use above code and remove refresh report and setlogondatabase("user", "passwd") then succeed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After removing refreshreport, it become better.
but error is
The types of the parameter field and parameter field current values are not compatible
i have checked id i passed is convert.toint32 and must be integer, and the rest is string
do not know why have types error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After follow csharp_win_rangeparameters, still is missing parameters
objRpt = new ReportDocument();
string reportPath = Server.MapPath("./Reports/CompanyCode_TT_PrintOut_HP2420_PCL6.rpt");
objRpt.Load(reportPath);
//The viewer's reportsource must be set to a report before any parameter fields can be accessed.
CrystalReportViewer1.ReportSource = objRpt;
//Get the collection of parameters from the report
crParameterFields = CrystalReportViewer1.ParameterFieldInfo;
//Access the specified parameter from the collection
crParameterField = crParameterFields["Cheque_IssueRecord_Secretary_Review_TT_ID"];
//Get the current values from the parameter field. At this point there are zero values set.
crParameterValues = crParameterField.CurrentValues;
//Set the current values for the parameter field
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = Request.QueryString["Cheque_IssueRecord_Secretary_Review_TT_ID"].ToString();
//Add the first current value for the parameter field
crParameterValues.Add(crParameterDiscreteValue);
//Access the specified range parameter from the collection.
crParameterField2 = crParameterFields["tCOMDB"];
//Get the current values from the parameter field. At this point there are zero values set.
crParameterValues2 = crParameterField2.CurrentValues;
//Set the current values for the parameter field
crParameterDiscreteValue2 = new ParameterDiscreteValue();
crParameterDiscreteValue2.Value = Request.QueryString["tCOMDB"].ToString();
//Add the current range value for the parameter field
crParameterValues.Add(crParameterDiscreteValue2);
/* Set the modified parameters collection back to the viewer so that
the new parameter information can be used for the report. */
CrystalReportViewer1.ParameterFieldInfo = crParameterFields;
CrystalReportViewer1.RefreshReport();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See if the samples csharp_win_multirangeparam.zip, csharp_win_paramengine.zip, csharp_win_rangeparameters.zip will help.
You do not mention version of CR or version of .NET - both would be minimal pieces of info, but do make sure you are on the latest SP for your version of CR and that the version of CR is supported in your version of .NET...
- Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.