Link to home
Start Free TrialLog in
Avatar of ybt
ybt

asked on

ActiveReports with paramerters in C#

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?
Avatar of HainKurt
HainKurt
Flag of Canada image

are you setting the value? also how do you use this parameter? in a select query?
Avatar of ybt
ybt

ASKER

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'%>
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
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

Avatar of ybt

ASKER

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#
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...
ASKER CERTIFIED SOLUTION
Avatar of ybt
ybt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial