Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Passing Parameter to crystal report is not working

$
0
0

Hello everyone. I have developed a web based inventory and accounts system using c# in VS2010, Sql server 2008 and Crystal Reports for VS2010. I am Passing parameters to a test crystal report as under the following which seems to work fine only for the first time but don't update the parameter value subsequent times.

privatevoidSetDate1AndDate2Parameters(ReportDocumentRptDoc)
   
{
       
ParameterFieldDefinition PFD =RptDoc.DataDefinition.ParameterFields["ParamDate1"];
       
ParameterValues PV =newParameterValues();
       
ParameterDiscreteValue PDV=newParameterDiscreteValue();

        PDV
.Value=Convert.ToDateTime(TextBox1.Text);
        PV
.Add(PDV);
        PFD
.ApplyCurrentValues(PV);
}

When i change the value for the parameter that changed value is not reflected in the parameter on crystal reports. There is another way of passing parameters i have come to know after googling i.e. to use crystalreportviewer.ParameterFieldsInfo i.e.

privatevoidSetDate1AndDate2Parameters(ReportDocumentRptDoc)
   
{

       
ParameterFieldsPFs=newParameterFields();
       
ParameterFieldPFDate1=newParameterField();
       
ParameterDiscreteValuePDVDate1=newParameterDiscreteValue();
       
PFDate1.Name="ParamDate1";
       
PDVDate1.Value=Convert.ToDateTime(Date1TextBox.Text.Trim());
       
PFDate1.CurrentValues.Add(PDVDate1);
       
PFs.Add(PFDate1);

       
ParameterFieldPFDate2=newParameterField();
       
ParameterDiscreteValuePDVDate2=newParameterDiscreteValue();
       
PFDate2.Name="ParamDate2";
       
PDVDate2.Value=Convert.ToDateTime(Date2TextBox.Text.Trim());
       
PFDate2.CurrentValues.Add(PDVDate2);
       
PFs.Add(PFDate2);

       
// Method
       
ParameterFieldPFMethod=newParameterField();
       
ParameterDiscreteValuePDVMethod=newParameterDiscreteValue();
       
PFMethod.Name="ParamMethod";
       
PDVMethod.Value=MethodDDL.SelectedValue;
       
PFMethod.CurrentValues.Add(PDVMethod);
       
PFs.Add(PFMethod);

       
// for Currency.

       
ParameterFieldPFCurrency=newParameterField();
       
ParameterDiscreteValuePDVCurrency=newParameterDiscreteValue();
       
PFCurrency.Name="ParamCurrency";
       
PDVCurrency.Value=CurrencyDDL.SelectedValue;
       
PFCurrency.CurrentValues.Add(PDVCurrency);
       
PFs.Add(PFCurrency);

       
// for currency rates
       
ParameterFieldPFCurrencyRate=newParameterField();
       
ParameterDiscreteValuePDVCurrencyRate=newParameterDiscreteValue();
       
PFCurrencyRate.Name="ParamCurrencyRate";
       
PDVCurrencyRate.Value=GetCurrentCurrencyRate();
       
PFCurrencyRate.CurrentValues.Add(PDVCurrencyRate);
       
PFs.Add(PFCurrencyRate);

       
CrystalReportViewer1.ParameterFieldInfo=PFs;
       
   
}

 


By using CrystalReportViewer1.ParameterFieldInfo is working for me but when the page is postback by pressing any other button e.g. a Button to show up Modal Box to change the parameters or Refresh button that will cause the report to get refresh is causing Error to display on CrystalReport viewer. I am unable to figure out what event i do require to handle so that this Error thing doesnot come.

 

I am desperately waiting for your guidance.


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>