Solved

ActiveReports with paramerters in C#

Posted on 2010-09-08
7
998 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
  • 4
  • 3
7 Comments
 
LVL 51

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 51

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 51

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 51

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

785 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