Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 2nd, 2004, 01:11 PM
Registered User
 
Join Date: Jan 2004
Location: chennai, TamilNadu, India.
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
Reply With Quote
The Following User Says Thank You to tbhakee For This Useful Post:
Dili1234 (September 11th, 2013)
  #2 (permalink)  
Old January 4th, 2005, 04:00 PM
Registered User
 
Join Date: Jan 2005
Location: Agawam, ma, USA.
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


Reply With Quote
  #3 (permalink)  
Old May 25th, 2005, 11:39 AM
Registered User
 
Join Date: Oct 2004
Location: Logan, UT, USA.
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?
Reply With Quote
  #4 (permalink)  
Old May 26th, 2005, 12:31 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik Send a message via Skype™ 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.
Reply With Quote
  #5 (permalink)  
Old June 1st, 2005, 03:04 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
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???



Reply With Quote
  #6 (permalink)  
Old April 16th, 2006, 02:09 PM
Registered User
 
Join Date: Jan 2004
Location: chennai, TamilNadu, India.
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to tbhakee
Default

Thanks sancy2k.

Loving,
Ŗhakee.T
Reply With Quote
  #7 (permalink)  
Old July 14th, 2006, 10:16 PM
Registered User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: Madison, Wisconsin, USA.
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?
Reply With Quote
  #8 (permalink)  
Old July 29th, 2006, 02:30 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
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!
Reply With Quote
  #9 (permalink)  
Old May 21st, 2007, 02:09 AM
Registered User
 
Join Date: May 2007
Location: Delhi, New Delhi, India.
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
Reply With Quote
  #10 (permalink)  
Old July 24th, 2008, 03:52 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2008
Location: , , .
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


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 01:16 AM
passing parameters at runtime using crystal report anilkumar Crystal Reports 2 January 3rd, 2004 12:35 AM



All times are GMT -4. The time now is 07:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.