473,387 Members | 1,876 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,387 software developers and data experts.

Why Enter Parameter value Window pops up?

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
2 2387
Sep410
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
7,872 Expert 4TB
In the original code you used "ActivityID" in the sql cmd, but set the parameter "ActivityId".
Case matters.
Aug 26 '08 #3

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

Similar topics

1
by: Chuck | last post by:
I have a query that uses the query with the critera set to . We I run the query the msgbox pops up asking for the name information to be entered, but on the top (blue background) of the message box...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
2
by: lgo | last post by:
I have read several variations of this topic posted on this news group. However I was not able to find the answer for my problem. I am trying to build code (see below) to update a large single...
0
by: Soeren S. Joergensen | last post by:
Hi, When entering an invalid value in a PropertyGrid, say entering 'A' where a numeric value is expected, a window pops up with an error. Is it possible to replace this window, or at least...
8
by: Jimmy | last post by:
I changed the name of a field in one of my tables (before you all scold me, don't, I won't ever, ever, ever do it again!) and then changed all of the references to it on the only form that uses...
2
by: billtubbs | last post by:
Hi I am getting the common problem of the "Enter Parameter Value" dialog box, which pops up every time I execute a query. I built the query using the Expression Builder in Access. If any of my...
1
by: waltnixon | last post by:
I've got an MS Access query which runs fine when double clicked and returns all of the rows in a test database I'm building. I've set up a multi group report based on the query. I immediately...
3
by: myemail.an | last post by:
Hi all, I use Access 2007 and have come across this error a number of times. I have two tables (customer information) which should contain - ideally - the same data. I create a query to compare...
18
by: pinky8 | last post by:
I have an ASP page with a button and other things. When the button is clicked, it executes a javascript function which does: document.Form1.method = 'post'; document.Form1.action =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.