Solved

ActiveReports with paramerters in C#

Posted on 2010-09-08
7
1,038 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 55

Expert Comment

by:Huseyin KAHRAMAN
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 55

Expert Comment

by:Huseyin KAHRAMAN
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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
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 55

Expert Comment

by:Huseyin KAHRAMAN
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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