473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Passing parameterto Crystal report in vb.net

77
Hi all,

I have a report in Vb.net and I used Crystal report viewer contorol.

The problem is I have 2 prameter in my report and I don't know how to pass the value to them.

Expand|Select|Wrap|Line Numbers
  1.   Dim rpt As New rptOpenCase()
  2.         Dim con As SqlConnection
  3.         Dim sql As String
  4.         Dim da As New SqlDataAdapter
  5.         Dim ds As New DataSet
  6.         con = New SqlConnection(strCon)
  7.         con.Open()
  8.         sql = " SELECT     [Case ID], [Open Date], Name, Worker, Service, [Issue Type], Fee,OD"
  9.         Sql &= " FROM dbo.vOpenCase "
  10.         If txtStartdate.Text <> "" And txtEndDate.Text <> "" Then sql &= " WHERE     (OD BETWEEN '" & txtStartdate.Text & "' AND '" & txtEndDate.Text & "')"
  11.  
  12.         da = New SqlDataAdapter(Sql, con)
  13.         da.Fill(ds)
  14.         rpt.Refresh()
  15.         rpt.SetDataSource(ds.Tables(0))
  16.         CrystalReportViewer1.ReportSource = rpt
  17.         rpt.Refresh()
  18.         CrystalReportViewer1.Zoom(75)
  19.         Publicds = ds.Copy()
I tried so many things that I found on the net but none of them worked.I need exact code.

I just want to show txtStartDate and txtEndDate on top of my report.

Please help me.
Sep 4 '08 #1
3 1252
kenobewan
4,871 Expert 4TB
Does &= work, I use += instead. Your dates may need to be converted to dates, eg CDate. HTH.
Sep 5 '08 #2
Sep410
77
Thanks for reply but all the other things in my code is working fine.
I need to know how should I pass parameter to crystal report.
Sep 5 '08 #3
Sep410
77
I found it:
Expand|Select|Wrap|Line Numbers
  1.       Dim paramFields As New CrystalDecisions.Shared.ParameterFields()
  2.                 Dim paramField As New CrystalDecisions.Shared.ParameterField()
  3.                 Dim discreteVal As New CrystalDecisions.Shared.ParameterDiscreteValue()
  4.                 Dim paramField2 As New CrystalDecisions.Shared.ParameterField()
  5.                 Dim discreteVal2 As New CrystalDecisions.Shared.ParameterDiscreteValue()
  6.  
  7.                 paramField.ParameterFieldName = "s"
  8.                 Dim str As String = txtStartdate.Text.ToString
  9.                 discreteVal.Value = str
  10.                 paramField.CurrentValues.Add(discreteVal)
  11.                 paramFields.Add(paramField)
  12.  
  13.  
  14.  
  15.                 paramField2.ParameterFieldName = "E"
  16.                 Dim str2 As String = txtEndDate.Text.ToString
  17.                 discreteVal2.Value = str2
  18.                 paramField2.CurrentValues.Add(discreteVal2)
  19.                 paramFields.Add(paramField2)
  20.                 CrystalReportViewer1.ParameterFieldInfo = paramFields
Sep 8 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: kvrdev1 | last post by:
I have a simple Crystal Report developed within .NET. Currently, it displays all fields from a view. Could someone please tell me how I could pass a parameter to the report to only display the...
1
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to...
0
by: stephan | last post by:
I know that this has been beaten to death but I can't seem to resolve my issues (I have 2 of them). I have created a class that exposes a public method which returns a datatable as a datasource...
1
by: raf_z | last post by:
Hi, I'm running a website with Asp.NET, and on one of the pages i have a crystal report with 3 user-populated parameters. However, not all params might be selected. Example: Parameters: 1....
1
by: Mariame | last post by:
Hi Everyone, i use crystal report & in the "Field Explorer" i select the table that i want to appear in report & make a "Where" Clause & i determine some parameters. The problem is How can to...
0
by: lewindha | last post by:
Hi all I am new to ASP.Net and Crystal Reports. We have VS.Net 2003 and Crystal 10 where I work. I have successfully been able to view reports in a web page. My problem now is that I have a...
1
by: momo | last post by:
Hello, How do I pass an sql query to the crystal report? For example "Select * from products where productid = 215" how can i build a crystal report in vb.net based on this query which returns...
1
by: gzali | last post by:
hi, i want to send parameter on web by using crystal report,the problem is that i am using crystal report 8.5 i am using a heperlink on a report filed, when the user click on the heperlink the...
1
by: imtmub | last post by:
Hi All, I have mainpage (POselect.aspx). language VB In that page i have a textbox (txtPOId) and command button(Button1) When i press then button its should send the textbox value to Crystal...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.