Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 2nd, 2004, 02:11 PM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to tbhakee
Default Passing parameters to crystal reports at runtime

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
The Following User Says Thank You to tbhakee For This Useful Post:
Dili1234 (September 11th, 2013)
 
Old January 4th, 2005, 05:00 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old May 25th, 2005, 11:39 AM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old May 26th, 2005, 12:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

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.
 
Old June 1st, 2005, 03:04 AM
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 "[u]Type 'ParameterFields' not defined</u>" , 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???



 
Old April 16th, 2006, 02:09 PM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to tbhakee
Default

Thanks sancy2k.

Loving,
ßhakee.T
 
Old July 14th, 2006, 10:16 PM
Registered User
 
Join Date: Jul 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old July 29th, 2006, 02:30 PM
Registered User
 
Join Date: Dec 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:
Code:
CrystalDecisions.Shared
:)Hope this helps!
 
Old May 21st, 2007, 02:09 AM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ravishdhingra82 Send a message via Yahoo to ravishdhingra82
Default

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
 
Old July 24th, 2008, 03:52 AM
Registered User
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/cryst...er_integer.htm


leveena







Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameters to crystal reports Shubhi ASP.NET 2.0 Professional 0 July 4th, 2008 02:18 AM
Passing parameters w/o prompt to Crystal Reports VannAustin BOOK: Professional Crystal Reports for VS.NET 1 August 31st, 2006 08:46 AM
Passing Parameters to crystal reports through codi secrets Crystal Reports 0 April 5th, 2005 01:44 PM
Passing parameters w/o prompt to Crystal reports VannAustin VB How-To 0 March 2nd, 2005 02:16 AM
passing parameters at runtime using crystal report anilkumar Crystal Reports 2 January 3rd, 2004 01:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.