By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Why Enter Parameter value Window pops up?

P: 77
Hi all,
I am using vb.net and Sql2005 and crystal report viewer in my application. the peroblem is when I run a report and I set the value for parameter a Enter Parameter value pops up.I shoudl re-enter the value then the report works.

What is wrong with this code:


Expand|Select|Wrap|Line Numbers
  1. Dim con As SqlConnection
  2.         Dim sql As String
  3.         Dim da As New SqlDataAdapter
  4.         Dim ds As New DataSet
  5.         Dim rpt As New CrystalReport1()
  6.         Dim crParameterFieldDefinitions As ParameterFieldDefinitions
  7.         Dim crParameterFieldDefinition As ParameterFieldDefinition
  8.         Dim crParameterValues As New ParameterValues
  9.         Dim crParameterDiscreteValue As New ParameterDiscreteValue
  10.  
  11.         con = New SqlConnection(strCon)
  12.         con.Open()
  13.         sql = "SELECT     ActivityTyID, ActTyDescription, ActivityID   FROM         dbo.tbl_ActivityType  WHERE     (ActivityID = '" & TextBox1.Text & "')"
  14.         da = New SqlDataAdapter(sql, con)
  15.         da.Fill(ds)
  16.         rpt.Refresh()
  17.         rpt.SetDataSource(ds.Tables(0))
  18.  
  19.         crParameterDiscreteValue.Value = Int(TextBox1.Text)
  20.         crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields()
  21.         crParameterFieldDefinition = crParameterFieldDefinitions.Item("ActivityId")
  22.         crParameterValues = crParameterFieldDefinition.CurrentValues
  23.         rpt.Refresh()
  24.         crParameterValues.Clear()
  25.         crParameterValues.Add(crParameterDiscreteValue)
  26.         crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
  27.         CrystalReportViewer1.ReportSource = rpt
  28.         rpt.Refresh()
  29.         CrystalReportViewer1.Zoom(75)
Aug 26 '08 #1
Share this Question
Share on Google+
2 Replies


P: 77
I found this and it is working:
Expand|Select|Wrap|Line Numbers
  1.       Dim con As SqlConnection
  2.         Dim sql As String
  3.         Dim da As New SqlDataAdapter
  4.         Dim ds As New DataSet
  5.  
  6.  
  7.         con = New SqlConnection(strCon)
  8.         con.Open()
  9.         sql = "SELECT     ActivityTyID, ActTyDescription, ActivityID   FROM         dbo.tbl_ActivityType  WHERE     (ActivityID = '" & TextBox1.Text & "')"
  10.         da = New SqlDataAdapter(sql, con)
  11.         da.Fill(ds)
  12.         Dim cr As New ReportDocument
  13.         cr.Load(cls.pathing() + "\Reports\CrystalReport1.rpt")
  14.         MsgBox(cls.pathing())
  15.         cr.SetDataSource(ds.Tables(0))
  16.         cr.SetParameterValue("ActivityID", TextBox1.Text)
  17.         CrystalReportViewer1.ReportSource = cr
Aug 26 '08 #2

Plater
Expert 5K+
P: 7,872
In the original code you used "ActivityID" in the sql cmd, but set the parameter "ActivityId".
Case matters.
Aug 26 '08 #3

Post your reply

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