error when previewing report using parameters for sql query

Stimulsoft Reports.Flex discussion
Locked
Rick
Posts: 6
Joined: Fri Feb 04, 2011 2:58 pm
Location: Colorado

error when previewing report using parameters for sql query

Post by Rick »

We are using 2011.1.917 of the flex report designer and we are trying to pass sql parameters at runtime using the following sql query for the datasource:

select * from detail where id='{id}' and date>='{startdate}' and date<='{enddate}'

Here is the copy of the flex code we are using to pass the parameters:

var mFromAmPm:int = cFrom.ampm.selectedValue as int;
var agent_id:String = "";

var mFromHours:int = cFrom.hours.value;
if (mFromHours == 12 &&mFromAmPm == 1)
{
mFromHours = 0;
}
var mFromMin:int = cFrom.minutes.value;

var mFromDate:String = MYSQLDate.format(cFrom.date.selectedDate) + " " + doubleDigitFormat(mFromHours + 12*(mFromAmPm-1)) + ":" + doubleDigitFormat(mFromMin) + ":00";

var mToAmPm:int = cTo.ampm.selectedValue as int;
var mToHours:int = cTo.hours.value;
if (mToHours == 12 &&mToAmPm == 1)
{
mToHours = 0;
}

var mToMin:int = cTo.minutes.value;
var mToDate:String = MYSQLDate.format(cTo.date.selectedDate) + " " + doubleDigitFormat(mToHours + 12*(mToAmPm-1)) + ":" + doubleDigitFormat(mToMin) + ":00";

var mAgent:Object = cAgent.selectedItem as Object;
if (mAgent != null)
{
agent_id = mAgent.data as String;
}

var agentid:StiDataParameter = vWreport.dictionary.dataSources.getByName("agentscalls").parameters.getByName("id");
if (id != null)
{
agentid.value = id;
}

var startdate:StiDataParameter = vWreport.dictionary.dataSources.getByName("agentscalls").parameters.getByName("startdate");
if (startdate != null)
{
startdate.value = mFromDate;
}

var enddate:StiDataParameter = vWreport.dictionary.dataSources.getByName("agentscalls").parameters.getByName("enddate");
if (enddate != null)
{
enddate.value = mToDate;
}

vWreport.isRendered = false;

myView.report = vWreport;


we keep getting errors when we preview the report or try to run it in the report browser that the sql query syntax is wrong. any help would be appreciated.

Thanks!
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

error when previewing report using parameters for sql query

Post by Vladimir »

Hello, Rick

We reproduced this error, we will fix it in the next builds. At this moment you can use report variables as parameters:

Code: Select all

var agentid:StiVariable = vWreport.dictionary.variables.getByName("id");
if (id != null)
{
agentid.value = id;
}

var startdate:StiVariable = vWreport.dictionary.variables.getByName("startdate");
if (startdate != null)
{
startdate.value = mFromDate;
}
This feature is available in the latest prerelease build.

Thank you.
Rick
Posts: 6
Joined: Fri Feb 04, 2011 2:58 pm
Location: Colorado

error when previewing report using parameters for sql query

Post by Rick »

Thank you...when you say next release do you mean the one on april 1?
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

error when previewing report using parameters for sql query

Post by Andrew »

Hello,

We expect the release be life this week (30th March- 1st April). We are finishing our last tests.

Thank you.
Locked