Query with parameter

Stimulsoft Reports.Flex discussion
Locked
dennislee
Posts: 14
Joined: Tue Apr 02, 2013 5:41 am

Query with parameter

Post by dennislee »

Hi,

I am new to Stimulsoft and would like to know how I can pass a parameter value from Flex app to Stimulsoft designer for flex report using MySQL connection. For instance, in my Flex app, I would like to pass a country ID (say, called flexCountryID) to employee.mrt which is designed to have a direct MySQL connection and able to select * from empTable where countryID = flexCountryID

Can you please advise how I can do that? By following your demo, I am able to set up the flex app to have
var report:StiReport = new StiReport();
report.loadReportFromString(reportString);
var database:StiMySqlDatabase = new StiMySqlDatabase("orgConnection", "", "server=localhost;port=3306;database=org;uid=root;pwd=;", false);
report.dictionary.databases.clear();
report.dictionary.databases.add(database);
report.show();

Then in my employe.mrt, I just have a MySQL connection with select * from empTable and then when running the flex app, it works perfect but O then I just want to user to see only those employees in his country not all of them. That is why I would like to know how to select only those country employee. Filtering variable is not an option I am looking for because the user can retrieve other country employee as well.

Hope to hear soon. Thanks.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Query with parameter

Post by HighAley »

Hello.

You should create a variable in the report, for example, flexCountryID.
And change your query:

Code: Select all

select * from empTable where countryID = {flexCountryID}
To set the value of this variable you can use next code:

Code: Select all

var v: StiVariable = report.dictionary.variables.getByName("flexCountryID");
v.valueObject = 10; // can also take string and boolean values
Thank you.
Locked