|
-
Jan 2nd, 2009, 10:36 AM
#1
Thread Starter
Hyperactive Member
Seems silly to have to create a parameter that is already part of report?
I am using the following code to set a parameter in my report.
Code:
Dim paramList As New Generic.List(Of Microsoft.Reporting.WinForms.ReportParameter)
dim TestString as string
TestString = "hello world"
paramList.Add(New Microsoft.Reporting.WinForms.ReportParameter("paramTitle", TestString))
ReportViewer1.LocalReport.SetParameters(paramList)
However, if I create the parameter at design time, it seems like I should be able to do something much simpler like
Code:
Microsoft.Reporting.WinForms.ReportParameter("paramTitle", TestString)
since the parameter is already created. However, I can't get anything like that to work.
Is this logic bad somewhere?
Thanks,
Dave
-
Jan 2nd, 2009, 04:57 PM
#2
Re: Seems silly to have to create a parameter that is already part of report?
Code:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
'
' Load the selected report file.
'
Dim CR As New ReportDocument
CR.Load(strReportPath)
'
' Declare the parameter related objects.
'
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
'
' Get the report's parameters collection.
'
crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
'
' Set the first parameter
' - Get the parameter, tell it to use the current values vs default value.
' - Tell it the parameter contains 1 discrete value vs multiple values.
' - Set the parameter's value.
' - Add it and apply it.
' - Repeat these statements for each parameter.
'
crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = strStartDate
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
'
' Set the Crytal Report Viewer control's source to the report document.
'
CrystalReportViewer.ReportSource = CR
If the parameters were added to your Crystal Report by clicking the Parameter Fields node in the Crystal IDE's Field Explorer they can be set using the following code:
Code:
Dim cr As New ReportDocument
cr.Load(strReportPath)
cr.SetDataSource(DS.Tables("Customers"))
cr.SetParameterValue("StartDate", strMyParmValue)
CrystalReportViewer.ReportSource = cr
-
Jan 2nd, 2009, 05:02 PM
#3
Thread Starter
Hyperactive Member
Re: Seems silly to have to create a parameter that is already part of report?
jggtz, that is for a crystal report, I'm using microsoft reporting services (rdlc file)
-
Jan 3rd, 2009, 12:42 AM
#4
Re: Seems silly to have to create a parameter that is already part of report?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|