Multiple parameters with user defined variables in query

Stimulsoft Reports.WEB discussion
Post Reply
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Multiple parameters with user defined variables in query

Post by kgb2013 »

I am trying to use multiple parameters in a query like here:
http://forum.stimulsoft.com/viewtopic.p ... t=10#p5910
Please declare a variable "ClientListId" in the report's Dictionary. Type of the variable please set 'object'.

SQL query should like something like this:

select * from Categories where CategoryID in ({ClientListId})

report.Load(....); //Load Template
report.Compile();
report["ClientListId"] = "1, 2, 3, 4";
report.Show();
My query uses both varables from the user and from the code.
I have noticed that when opening the report in the MVC Viewer a correct query is being executed, but when the user submits his variables from the viewer the query sent becomes this:
declare @p1 int
set @p1=NULL
exec sp_prepexec @p1 output,N'@grpID int,@FromDate datetime,@ToDate datetime',N'SELECT COUNT(*) as cnt
FROM MyTable
LEFT JOIN MyTable2 ptc
ON doc.IdDocument=ptc.IdDocument
WHERE doc.IdDocumentType=3 AND doc.IssueDate>=@FromDate AND doc.IssueDate<=@ToDate AND ptc.IdOrgGroup IN (System.Object)
',@grpID=0,@FromDate='2010-12-01 12:13:22',@ToDate='2013-12-09 12:13:22'
select @p1
..while it should be this:
declare @p1 int
set @p1=4
exec sp_prepexec @p1 output,N'@grpID int,@FromDate datetime,@ToDate datetime',N'SELECT COUNT(*) as cnt
FROM MyTable
LEFT JOIN MyTable2 ptc
ON doc.IdDocument=ptc.IdDocument
WHERE doc.IdDocumentType=1 AND doc.IssueDate>=@FromDate AND doc.IssueDate<=@ToDate AND ptc.IdOrgGroup IN (22,32)
',@grpID=0,@FromDate='2013-12-09 12:18:53.203',@ToDate='2013-12-09 12:18:53.203'
select @p1
Am I missing something?
Why does it work the 1st time and not when the user submits his variables (@grpID,@FromDate,@ToDate)?

Should I have anything more in my "interaction" Controller Action other than this? :

Code: Select all

return StiMvcViewer.InteractionResult(HttpContext);
Thanks.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Multiple parameters with user defined variables in query

Post by HighAley »

Hello.

If you have list variable then ,please, try to use next query:

Code: Select all

select * from customers where id in ({Variable1.ToQueryString()})
Thank you.
kgb2013
Posts: 85
Joined: Fri Nov 01, 2013 9:52 am
Location: Earth

Re: Multiple parameters with user defined variables in query

Post by kgb2013 »

Hello.

No, it's an object variable, just like it is mentioned in the first quote.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Multiple parameters with user defined variables in query

Post by HighAley »

Hello.

Please, send us a sample project which reproduces the issue.

Thank you.
Post Reply