469,304 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

Missing Parameter values in Crystal reports

When i run the page i'm getting a message showing."Missing Parameter values" and want display the report. i've used following formula
Expand|Select|Wrap|Line Numbers
  1. Year ({tbl_DisasterRegistration.Date})  =  Year (CurrentDate)  - {?@YearCount}
By right click on the report...Report->Selection Formula->Record

my code is used in DropDownList1_SelectedIndexChanged

Expand|Select|Wrap|Line Numbers
  1. ReportDocument crystalReport = new ReportDocument();
  2.             crystalReport.Load(Server.MapPath(@"/Presentation Layer/Reports/YearlyStatistics.rpt"));
  3.             crystalReport.SetDatabaseLogon("", "", "XPWINDOWS7\\SQLEXPRESS", "PODRAS_MS");
  4.             ParameterFieldDefinitions crParameterFieldDefinitions;
  5.             ParameterFieldDefinition crParameterFieldDefinition;
  6.  
  7.             ParameterValues crParameterValues = new ParameterValues();
  8.             ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
  9.  
  10.  
  11.             crParameterDiscreteValue.Value = Convert.ToInt32(DropDownList1.SelectedItem.Value);
  12.             crParameterFieldDefinitions = crystalReport.DataDefinition.ParameterFields;
  13.             crParameterFieldDefinition = crParameterFieldDefinitions["@YearCount"];
  14.             crParameterValues = crParameterFieldDefinition.CurrentValues;
  15.  
  16.             crParameterValues.Clear();
  17.             crParameterValues.Add(crParameterDiscreteValue);
  18.             crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
  19.  
  20.             CrystalReportViewer1.ReportSource = crystalReport;
  21.             CrystalReportViewer1.RefreshReport();
i also tried this on page load event by giving
Expand|Select|Wrap|Line Numbers
  1. crParameterDiscreteValue.Value =1
same error occurs???

can anyone help???
Jul 25 '10 #1
3 9811
Jyoti Ballabh
115 100+
maybe, you need to reset the parameter as follows-

Expand|Select|Wrap|Line Numbers
  1. ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
  2. ParameterRangeValue rangeVal = new ParameterRangeValue();
  3. ParameterValues curvalues = new ParameterValues();
  4. foreach (ParameterFieldDefinition parafld in 
  5.              crReport.DataDefinition.ParameterFields)
  6. {
  7.   if (parafld.DiscreteOrRangeKind.ToString() == "DiscreteValue")
  8.   {
  9.     discreteVal.Value =
  10.  
  11.            Request.QueryString[parafld.ParameterFieldName];
  12.     if (discreteVal.Value != null)
  13.     {
  14.       curvalues.Add(discreteVal);
  15.       parafld.ApplyCurrentValues(curvalues);
  16.     }
  17.   }
  18.  
  19. }
Jul 25 '10 #2
cr4sh
20
your approach to the whole problem is great. have a look at the parameter sequencing in the code below.....

Expand|Select|Wrap|Line Numbers
  1. Dim objReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
  2. Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
  3. Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
  4. Dim currValue As CrystalDecisions.Shared.ParameterValues
  5. Dim sParValPair() As String
  6. Dim sValue() As String
  7. Dim iIndex As Integer
  8. Dim crFieldDef As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions
  9. Dim crFieldLoc As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
  10. ConInfo.ConnectionInfo.ServerName = modLibrary.m_sDATASOURCE
  11. ConInfo.ConnectionInfo.DatabaseName = modLibrary.m_sDATABASE
  12. ConInfo.ConnectionInfo.IntegratedSecurity = True
  13. objReport.Database.Tables(intCounter).ApplyLogOnInfo(ConInfo)
  14. crFieldDef = objReport.DataDefinition.ParameterFields
  15. sParValPair = sParam.Split(";")
  16. For iIndex = 0 To UBound(sParValPair)
  17.    If InStr(sParValPair(iIndex), "=") > 0 Then
  18.       sValue = sParValPair(iIndex).Split("=")
  19.       crFieldLoc = crFieldDef.Item(sValue(0))
  20.       currValue = crFieldLoc.CurrentValues
  21.       paraValue.Value = sValue(1)
  22.       currValue.Add(paraValue)
  23.       crFieldLoc.ApplyCurrentValues(currValue)
  24.    End If
  25. Next iIndex
Jul 25 '10 #3
Thanks for the replies problem was resolved by removing
Expand|Select|Wrap|Line Numbers
  1. CrystalReportViewer1.RefreshReport();
Jul 26 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Scott Hatfield | last post: by
4 posts views Thread by touf | last post: by
1 post views Thread by Hardy Wang | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.