|
Subject:
|
Passing parameters to crystal reports at runtime
|
|
Posted By:
|
tbhakee
|
Post Date:
|
1/2/2004 1:11:39 PM
|
Help me in passing parameters to crystal reports at run time in vb.net with out showing that ugly enter parameter dialog. Another problem i encountered is when i iterate thro' the data in a data table and filter only a specific data based on a specific field ,i get blank lines for all those fields that were false ie. those that does not satisfy the condition.
Loving, ßhakee.T
|
|
Reply By:
|
katg1rlll
|
Reply Date:
|
1/4/2005 4:00:19 PM
|
Here's an easy way to pass parameters ' Declare variables needed to pass the parameters to the viewer control. Dim paramFields As New ParameterFields Dim paramField As New ParameterField Dim discreteVal As New ParameterDiscreteValue
' The first parameter is a discrete parameter with multiple values. ' Set the name of the parameter field, this must match a parameter in the report. paramField.ParameterFieldName = "@LevyYear" '*** SETTING THE FIRST DISCRETE VALUE & PASS IT TO THE PARAMETER *** discreteVal.Value = "Levy Year: " & glbLevyYear paramField.CurrentValues.Add(discreteVal) '*** ADDING THE PARAMETER TO THE PARAMETER FIELDS COLLECTION *** paramFields.Add(paramField)
'*** PASSING A SECOND PARAMETER (DISCRETE VALUE) *** paramField = New ParameterField paramField.ParameterFieldName = "@Description" discreteVal = New ParameterDiscreteValue discreteVal.Value = "Levy Year: " & glbLevyYear & " | Commitment Number: " & glbCommitNumber paramField.CurrentValues.Add(discreteVal) paramFields.Add(paramField) '*** DON'T FORGET TO ALWAYS ADD THE PARAMETER TO THE PARAMFIELDS AFTER ENTERING THE VALUE *** IT MUST BE ADDED AFTER EACH NEW PARAMETER ***
'*** SET THE PARAMETER FIELDS COLLECTION INTO THE VIEWER CONTROL *** crpViewer.ParameterFieldInfo = paramFields
|
|
Reply By:
|
brendalisalowe
|
Reply Date:
|
5/25/2005 11:39:41 AM
|
So after I have that setup, how do I incorporate that into my report? Where do I put the parameter to use it? Please help! Thanks!
__________________ Brenda
If it weren't for you guys, where would I be?
|
|
Reply By:
|
melvik
|
Reply Date:
|
5/26/2005 12:31:00 AM
|
Dear friend: what version of CR & VB u r useing?! If u use .NET I suggest to use DataSet Fill it with a DataAdapter & then pass DataSet to Report Obj. But if u still dont want, the given sample is quite OK.
Always , Hovik Melkomian.
|
|
Reply By:
|
sancy2k
|
Reply Date:
|
6/1/2005 3:04:26 AM
|
Hi there.. I use asp.net and crystal 9 for my proj.i facing the prob in passing parameter to crystal report. i tried the above solution on my webpage which contains the crystal report viewer, but i get the incorrect symptom of "Type 'ParameterFields' not defined" , thus i simply cant go forward with trying out the code given above... Am i on the wrong page?? i tried filling the dataset.the dataset gets filled but again, i am not able to pass the paramater... what should i do???
|
|
Reply By:
|
tbhakee
|
Reply Date:
|
4/16/2006 2:09:47 PM
|
Thanks sancy2k.
Loving, ßhakee.T
|
|
Reply By:
|
RKevinBurton
|
Reply Date:
|
7/14/2006 10:16:21 PM
|
How is this done for Windows Forms? I am trying to print a report and there isn't a viewer and I don't see a method or property ParameterInfo?
|
|
Reply By:
|
Gino
|
Reply Date:
|
7/29/2006 2:30:15 PM
|
Hi RKevinBurton, In windows forms you should find a crystal report viewer in the toolbar, should be the last one. Then you'll need to add a New Item to your project (from the solution explorer); you guessed it, a Crystal Report. Set up your crystal report and set the Report Source property of your crystal report viewer to the newly created crystal report (you'll need to browse to its location). And you'll need this namespace to declare parameter fields: CrystalDecisions.Shared Hope this helps!
|
|
Reply By:
|
ravishdhingra82
|
Reply Date:
|
5/21/2007 2:09:03 AM
|
Hi, My name is Ravish. I am having some problem while passing parameters for crystal report.
my syntax is cmd.parameters.add("@SLCODE",slcode) where slcode is an integer at front-end and @SLCODE is varchar in stored procedure.
Actually i am showing this report for every months as I am making payroll system. When I choose March My report opens automatically without any problem. But if I choose April It gives an error "Syntax error converting the varchar value null to coloumn of datatype int".
Also when I checked the syntax "cmd.parameters.add("@SLCODE",slcode)" in immidiate window. Ths syntax gives value "Nothing", but for march this syntax gives value "" (string).
Please if anyone have any idea about this error. do help me.ASAP
Thanks Regards RavishDhingra
Ravish Dhingra
|
|
Reply By:
|
leveena
|
Reply Date:
|
7/24/2008 3:52:14 AM
|
try this
Dim crParameterFieldDefinitions As ParameterFieldDefinitions Dim crParameterFieldDefinition As ParameterFieldDefinition Dim crParameterValues As New ParameterValues Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = Convert.ToInt32(TextBox1.Text) crParameterFieldDefinitions = _ cryRpt.DataDefinition.ParameterFields crParameterFieldDefinition = _ crParameterFieldDefinitions.Item("Price") crParameterValues = crParameterFieldDefinition.CurrentValues
check the following link
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_parameter_integer.htm
leveena
|