[Question][Stand Alone Report Designer]: Trying to rename data source field for parameter. How can I get this to work?

2 Answers 95 Views
DataSource SQL DataSources Expressions Programming Report Designer (standalone) Report Parameters
Austin
Top achievements
Rank 2
Iron
Iron
Iron
Austin asked on 14 Feb 2023, 10:33 PM

Currently, I have two different parameters. One uses Fields.ID the other needs to use Field.ID2 However, using the code below. I am unable to rename ID to ID2. If I use ID It modifies Parameter1's ID field instead of Parameter2's ID field. I need to use dual union to be able to select all employees but when I run it with the "AS" command for renaming ID to ID2 it errors out(see below code). If I run it without the dual union. It works and renames ID to ID2. But, then I do not have the ability to select all employees which I need. How can I fix this in the report designer? is there a better way or am I using my code wrong, what would be a good solution to this?

 

How can I get this to work and rename ID to ID2 for the second source using the code below so that I can still use the dual union?

 

[Doesn't work]

SELECT TO_NCHAR('All Employees') AS FirstName, TO_NCHAR('*') AS LastName, 0 AS ID FROM DUAL
UNION
select FirstName, LastName, ID AS ID2

FROM Personnel
ORDER BY LastName NULLS FIRST

 

[Works]

select FirstName, LastName, ID AS ID2

FROM Personnel
ORDER BY LastName NULLS FIRST

 

 

Thank you!

2 Answers, 1 is accepted

Sort by
1
Accepted
Todor
Telerik team
answered on 17 Feb 2023, 11:21 AM

Hello Austin,

The Reporting engine and the Report Designer wizards utilize the specified data provider to send the connections string and the query/stored procedure name to the database server. The SQL code is executed on the database server. We cannot control this and only use the data returned by the data provider.

From the Reporting side, you may use different SqlDataSources for the values of the two Report Parameters. The downside is that the database will be queried twice for the same data.

Regards,
Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
0
Austin
Top achievements
Rank 2
Iron
Iron
Iron
answered on 17 Feb 2023, 09:51 PM

Good Afternoon Todor,

So, I made a mistake in my original code and didn't realize I had already called an AS statement on ID in my first sentence.

 

I modified it to the following and it worked perfectly. Sorry for the confusion and my stupid question :P

 

SELECT TO_NCHAR('All Employees') AS FirstName, TO_NCHAR('*') AS LastName, 0 AS ID2 FROM DUAL
UNION
select FirstName, LastName, ID

FROM Personnel
ORDER BY LastName NULLS FIRST

Tags
DataSource SQL DataSources Expressions Programming Report Designer (standalone) Report Parameters
Asked by
Austin
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Todor
Telerik team
Austin
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or