Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ActiveReports with paramerters in C#

Posted on 2010-09-08
7
Medium Priority
?
1,082 Views
Last Modified: 2013-12-17
I placed SQL code in a datasource  field of my report and
put the following code in ReportStart event

Parameter myParam1 = new Parameter();
myParam1.Key = user_id;
myParam1.Type = Parameter.DataType.String;
myParam1.PromptUser = false;
this.Parameters.Add(myParam1);

But datasource does not receive parameter at all.
Could anybody tell what should I do?
0
Comment
Question by:ybt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 60

Expert Comment

by:HainKurt
ID: 33627704
are you setting the value? also how do you use this parameter? in a select query?
0
 

Author Comment

by:ybt
ID: 33627797
Yes, value set, I checked that and select query look like this:
SELECT  *    from memo m
 where m.memo_userid = <% myParam1|enter user id|'ALL'%>
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 33629262
but where do you set the value of this parameter?
i see you create a parameter, set its properties (but not the value, so value should be null by default) and query uses ALL because you never provided a value for your parameter
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 60

Expert Comment

by:HainKurt
ID: 33629275
here is a sample i found on net

you are missing

myParam1.DefaultValue = "This is myParam1 default value"

http://www.datadynamics.com/Help/ActiveReports6/arHOWAddParameters.html
Dim myParam1 As New Parameter()
myParam1.Key = "myParam1"
myParam1.Type = Parameter.DataType.String
myParam1.PromptUser = True 'set to False if you do not want input from user
myParam1.Prompt = "Enter last name:"
myParam1.DefaultValue = "This is myParam1 default value"
Me.Parameters.Add(myParam1)

Open in new window

0
 

Author Comment

by:ybt
ID: 33629690
I did not type it here, I checked with a messagebox, value is not null

Parameter myParam1 = new Parameter();
myParam1.Key = user_id;
myParam1.Value = s_user;
myParam1.Type = Parameter.DataType.String;
myParam1.PromptUser = false;
this.Parameters.Add(myParam1);
I saw that sample it is for VB lower there for C#
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 33629860
so you added this code to

Double-click in the gray area below the report to create an event-handling method for the ReportStart event.
Add code to the handler to change the data source at run time.

if you add this into ReportStart, then it should be fine...
0
 

Accepted Solution

by:
ybt earned 0 total points
ID: 33809065
Still not work, but I solved problem by creating a strored procedure in SQL Server with parameters and in ReportStart event created a datasource in code.
DataDynamics.ActiveReports.DataSources.SqlDBDataSource _ds = new DataDynamics.ActiveReports.DataSources.SqlDBDataSource();
_ds.ConnectionString = .connection string;..
_ds.SQL = "exec my stored procedure  " + my parameter + "";
this.DataSource = _ds;
It works.

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question