?
Solved

Pass in Parameter Value:  VB.NET ASP.NET

Posted on 2004-08-09
3
Medium Priority
?
8,525 Views
Last Modified: 2009-04-15
I am trying to pass a parameter value in from a textbox - right now am tryign to settle for hardcoding the param value and getting the report tp pick it up - here is the code that I am using now:
------------------------------------------
    Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        'Dim crReportDocument As DiscreteParam
        Dim crParameterFields As CrystalDecisions.Shared.ParameterFields
        Dim crParameterField As CrystalDecisions.Shared.ParameterField
        Dim crParameterValues As CrystalDecisions.Shared.ParameterValues
        Dim crParameterDiscreteValue As CrystalDecisions.Shared.ParameterDiscreteValue

        ''Create an instance of the strongly-typed report object
        'crReportDocument = New DiscreteParam()

        ''The viewer's reportsource must be set to a report before any
        ''parameter fields can be accessed.
        'CrystalReportViewer1.ReportSource = "C:\WebSites\WebSite3\rptEffectDateExcept.rpt"

        ''Get the collection of parameters from the report
        crParameterFields = CrystalReportViewer1.ParameterFieldInfo

        ''Access the specified parameter from the collection
        crParameterField = crParameterFields.Item("@prmMonth")

        ''Get the current values from the parameter field.  At this point
        ''there are zero values set.
        'crParameterValues = crParameterField.CurrentValues
        crParameterValues = crParameterField.DefaultValues
        ''Set the current values for the parameter field

        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue()
        crParameterDiscreteValue.Value = "1.00"

        ''Add the first current value for the parameter field
        crParameterValues.Add(crParameterDiscreteValue)

        ''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.ReportSource = "C:\WebSites\WebSite3\rptEffectDateExcept.rpt"
    End Sub
0
Comment
Question by:tbaseflug
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 11759318
0
 
LVL 1

Accepted Solution

by:
NissePPP earned 2000 total points
ID: 11760933
Here are an ex. how to pass a text to a Textfield in CR ( no parameterfield)

    Public Function add2textfield()
        Dim CR As New ReportDocument
        Dim temp As String
        'The loaction of the report
        temp = "C:\\WindowsApplication1\CrystalReport3.rpt"
        CR.Load(temp)

        Try
            Dim myReportTextObject As CrystalDecisions.CrystalReports.Engine.TextObject
            Dim myTestObject As CrystalDecisions.CrystalReports.Engine.ReportObject

            'The name of the textfield in CR: DescriptionText
            If TypeOf CR.ReportDefinition.ReportObjects.Item("DescriptionText") Is CrystalDecisions.CrystalReports.Engine.TextObject Then
             
                'The text that you want to show in your textfield
                CType(CR.ReportDefinition.ReportObjects.Item("DescriptionText"), _
                      CrystalDecisions.CrystalReports.Engine.TextObject).Text = _
                      "TEST"

            End If
        Catch err As Exception
            'the description text in the document won't be written
        End Try

        CrystalReportViewer1.ReportSource = CR
    End Function
0
 
LVL 10

Expert Comment

by:ebolek
ID: 11762002
You are using the viewer object model. iT is limited if you want to use some other runtime customizations. I would offer to use runtime customization with report engine object model. I use it all the time and it works. Here is the code that I wrote for parameters in report engine object model in C#. Convert it to VB.net

................
private  CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition SetReportParameters(CrystalDecisions.CrystalReports.Engine.ReportDocument MyReport)
      {
                  //sets the parameter values for main report and sub reports if any
      CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition ParameterFieldDefinition;
      CrystalDecisions.Shared.ParameterDiscreteValue  ParameterDiscreteValue;
      CrystalDecisions.Shared.ParameterValues  ParameterValues;                              
      int paramcount;
      paramcount = this.MyParameterValues.Count;
      ParameterFieldDefinition = null;
                                    
      for (int i = 0; i != paramcount; i++)//have to put paramcount otherwise hard code it .works
          {
                                                      ParameterFieldDefinition = MyReport.DataDefinition.ParameterFields[i];  
      ParameterValues = new CrystalDecisions.Shared.ParameterValues();
      ParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();      
      ParameterDiscreteValue.Value = this.MyParameterValues[i];      
      ParameterValues.Add(ParameterDiscreteValue);
      ParameterFieldDefinition.CurrentValues.Clear();
      ParameterFieldDefinition.DefaultValues.Clear();  
      ParameterFieldDefinition.ApplyCurrentValues(ParameterValues);
                        
       }            
      return ParameterFieldDefinition;
                                                
      }
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question