473,545 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why Enter Parameter value Window pops up?

77 New Member
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 2398
Sep410
77 New Member
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 Recognized Expert Expert
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
719
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 it says" Enter Parameter Value ". Is there anyway to change this to something that is not as generic. I appreciate any help you can give. ...
9
6980
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 it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with...
2
14860
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 record using data from a temporary (editing) table with identical field structure. I iterate through the fields (some 50 of them) with a For Each -...
0
1230
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 catch the error before window pops up, so I can present an understandable error description for the user ?? Kr. Soren
8
3228
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 that particular field. I change it in the underlying query and all of the code for that form. Problem is, MSAccess doesn't agree. When I open the form...
2
3254
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 expressions reference another column in the same query, it causes the dialog box to appear for each parameter before displaying the query output, even...
1
5051
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 began getting the "Enter Parameter Value" dialog and it was asking for the query by its name "sel_report_data" whenever I tried to run or preview the...
3
5436
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 them based on customer code. The fields are something like: Customer code Balance - Table 1 Balance - Table 2
18
2877
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 = "AnotherASPpage.asp?p1=" + allFields1 + "&p2=" + allFields2 + "&p3=" + bVar; document.Form1.submit(); allFields1 represents all the fields in...
0
7486
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7932
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7776
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
729
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.