Solved

ActiveReports with paramerters in C#

Posted on 2010-09-08
7
982 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
Comment Utility
are you setting the value? also how do you use this parameter? in a select query?
0
 

Author Comment

by:ybt
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 51

Expert Comment

by:HainKurt
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now