C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

For passing parameter from TextBox to Crystal report Using vb.Net


Posted Date: 08 Oct 2004    Resource Type: Articles    Category: .NET Framework
Author: prakash gurnuleMember Level: Bronze    
Rating: 1 out of 5Points: 10



For passing parameter from TextBox to Crystal Report follow following steps

1)add Crystal report and viewer in your project
2)on which field u want to add parameter is let's examples "Name" Field.

3)First In report Create parameter by right click on parameter field--> Name
4)In pop up enter Name as -->paraName
5)Second In report clicked on Database field-->Table Name--> Field Name(Here "Name" )
6)Right clicked on Name field-->click on Select Exert
7)Is equal to --> parameter Name({?paraName})


Dim param1Fileds As New CrystalDecisions.Shared.ParameterFields
Dim param1Field As New CrystalDecisions.Shared.ParameterField
Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim CRYRpt1 As New CrystalReport1

param1Field.ParameterFieldName = "paraName" ' Parameter Name In Crystal Report
param1Range.Value = TextBox1.Text ' value For Parameter Field
param1Field.CurrentValues.Add(param1Range)
param1Fileds.Add(param1Field) ' To add parameter in parameterslist
CrystalReportViewer1.ParameterFieldInfo = param1Fileds 'to pass parameter inf.to CRV
CrystalReportViewer1.ReportSource = CRYRpt1 ' Assign Report Source to CRV
CrystalReportViewer1.Refresh()
CrystalReportViewer1.Visible = True

End Sub




Responses

Author: Jim A.    28 Nov 2004Member Level: Bronze   Points : 0
I get the following error as usual: Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.

This is a HUGE problem on the internet. A careful search will result in a large number of people looking to solve this issue. Your code looked promising, but unfortunately it fails like all the rest.

If I ever find a real solution for passing parameters to Crystal Reports via Visual Studio .net I will update this post.

Until then, this code doesn not work. No need to waste time here.




Author: coco tech    01 Dec 2004Member Level: Bronze   Points : 0
The code above does work. If you want to call it that. I was able to compile and run it. My code, however was a direct translation of the above code into C#. Although it does run the parameters don't seem to return the expressions that I enter into the textbox. I will post when I get to that step.


Author: coco tech    01 Dec 2004Member Level: Bronze   Points : 0
The code above does work. If you want to call it that. I was able to compile and run it. My code, however was a direct translation of the above code into C#. Although it does run the parameters don't seem to return the expressions that I enter into the textbox. I will post when I get to that step.


Author: suman tiwari    18 Apr 2005Member Level: Silver   Points : 0
i have followed all the step as per above. but it dosent show me the value of text box into crystal repot.

it dosent work properly.




Author: Subrata Datta    14 Jun 2005Member Level: Bronze   Points : 0
it works for the first run. i added a textbox and a button after giving value to textbox press button against which code is written the result comes out. but when i am changing the contents of textbox then the screen add parameter value comes and the again i have to provide the value to it then the result comes out. it does not depend on the textbox. pls help


Author: Subhro Gupta    01 Aug 2005Member Level: Bronze   Points : 0
Hey,

I just modified ur code a bit and it works fine. Can anyone tell me that after this parameter is passed to CR, it does not filter the records as per the sql statement typed in the command window where the actually the parameter is passed. It shows me a blank record though the parameter has value

.NET
------

Dim param1Fileds As New CrystalDecisions.Shared.ParameterFields
Dim param1Field As New CrystalDecisions.Shared.ParameterField
Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue

param1Field.ParameterFieldName = "uid" ' Parameter Name In Crystal Report
param1Range.Value = "8558a876-a8a1-4de9-8be8-fc7304f95c66" ' value For Parameter Field
param1Field.CurrentValues.Add(param1Range)
param1Fileds.Add(param1Field) ' To add parameter in parameterslist
CrystalReportViewer1.ParameterFieldInfo = param1Fileds 'to pass parameter inf.to CRV
CrystalReportViewer1.ReportSource = "D:\Subhro\VB_NET Calling\Test.rpt" ' Assign Report Source to CRV
CrystalReportViewer1.Refresh()
CrystalReportViewer1.Visible = True



Crystal SQL in its command window
-------------------------------------------------

select repo_name, startdate, enddate from repo_gen where id = '{?uid}'



Pleaz pass a solution if u have one, immediately.


Author: Ami Desai    04 Jan 2006Member Level: Silver   Points : 0
I have write same code ...my programm take para value at runtime from textbox but also display dialogbox to again enter para fields


Author: Chan Lemo    25 May 2009Member Level: Bronze   Points : 2
crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = _
crParameterFieldDefinitions.Item("Customername")
crParameterValues = crParameterFieldDefinition.CurrentValues

http://vb.net-informations.com/crystal-report/vb.net_crystal_report_parameter_string.htm

lemo




Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Typed DataSet
Previous Resource: Continuous integration and best practices
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use