DataSet query with Parameters does not work in Report Builder - mysql

The following picture shows the query and its result with no variables:
The next one shows the same query with a variable and a different result:
This how the parameter was set just before the query execution:
I have also tried setting the parameter without '' but it produces the same result.
Any clue about what's going on? Any help would be greatly appreciated.
NOTE: The DBMS is MySql

This weird issue is due to the fact that SSRS is connected to MySQL by ODBC connector; therefore, the query parameters should be defined as ? and their names are Parameter1, Parameter2, etc... in order of appearance
Source: http://www.tek-tips.com/viewthread.cfm?qid=1354185

In Report Builder 3.0 you can user parameters in a dataset query using the following syntax:
WHERE sql_column_name = (#Parameter_name_in_ReportBuilder)
Example:
SELECT * from [dbName].[dbo].[TableName]
WHERE Account=(#Parameter1)
Before you can run the report, you need to configure a paramter named Parameter1 (in this example, change this to the name of your parameter) in Dataset Properties - Parameters. The value field should be set to one of the parameters

Related

MySQL + SSRS (SQL Server Report Builder) Dataset/Query Parameters not working

I am currently using SQL Server Report Builder 2012 and is connected to my MySQL Database via an ODBC Connector and as far as base report goes, all is well.
However, i can't seem to make the Query/Dataset Parameters to work the way its supposed to be. I have multiple parameters to my query as you can see below (obviously table and column names are removed):
Now the problem is, if i leave the parameters as is (#OfMonth, #OfDay, #OfYear) - SSRS does not seem to bind the actual values passed from the Report Builder's Parameter Object which i am confident to day that i have associated properly. Not even on the preview/query designer.
However, if i change all #XXXX parameters to simple ? placeholders, it magically works. This poses as issue specially with queries that have multiple parameters.
This is the Report Builder's screenshot of my Work in Progress:
i have no issues defining the 3 Parameter object under the Parameter Node. However, if i try to bind them under Dataset Properties with specific #XXXXX placeholders, it doesn't work, and the report fails to generate data. But if i replace all #XXXXX with ? (all of them are just ?, therefore duplicates), the parameter gets passed and the report loads.
For ODBC connections, you do need to use a ? instead of named variables.
dba.stackexchange | Pass Parameter - SSRS to MySQL
The Parameter Name field on the Dataset Properties should auto-fill with Parameter1, Parameter2,... to match your query but doesn't always seem to work. You can try adding them manually. Since it worked without the name for you, I assume the name doesn't actually matter.
When I would have a parameter used multiple times, I would declare a new one in the query and reuse the new one as #Bacon mentioned:
DECLARE #OfMonth INT
SET #OfMonth = ?
This way you only have to match them once at the beginning of your query.
Use ? as variable in your script, then remember specific order of '?' then using specific order/arrangement of '?' parameters, setup them in the parameter tab after you add the MySQL script.
Ex. Script.
Select * from table1
where column1 = ?
and column2 = ?
When you paste this on the dataset, each '?' will be mapped in the parameter tab.
? Parameter1
? Parameter2
Change this to your own parameters then you're good to go.

SSS Report Builder 3.0 Query Parameter - Report Preview

This is a bit strange to me. I am using a SSRS Report Builder 3.0 for creating a report. I have two options: 1. Use a filter linked with report parameter OR 2. Use a query parameter linked with report parameter.
In the first case, the report preview works perfect. I am using a simple query for filter with parameter (#parameter_a) applied on ID column:
Select ID, Name from tbl_Table
But when I use a query parameter linked to the report parameter, the preview is blank. For the query parameter, I use the below query:
SELECT ID, Name FROM tbl_Table WHERE ID = #parameter_a
I am clueless on this. I have also tried keeping a default value or removing it. Refresh/View Report doesn't work either.
PS: I am using MySql ODBC connection. Both options in report work fine when used in a c# application and rendered programatically. Tried re-installing current version, older version as well.
Reading the MySQLCommand documentation, there is reference to an older parameter syntax (not sure what version of MySQL you are using in this scenario).
Using the '#' symbol for paramters is now the preferred approach
although the old pattern of using '?' is still supported. Please be
aware though that using '#' can cause conflicts when user variables
are also used. To help with this situation please see the
documentation on the 'allow user variables' connection string option.
The 'old syntax' connection string option has now been deprecated.
Instead of using #, can you try with ?:
SELECT ID, Name FROM tbl_Table WHERE ID = ?
The order of the parameters used in the query will have to match the order of the SSRS report parameters.

SSRS: How to add All option to SSRS dropdown filter?

I'm using SQL Server Reporting Services for SQL 2008 R2. My reports are filtered by two drop-down menus that are populated from a table, one of them displays a build number. I'd like to give users the option to choose "All" and so return data for all build numbers and not just one.
How do I add this option to my drop-down filter and make it work correctly?
Thanks very much for any help provided.
J.
I'm assuming you don't want to use a multi-value parameter here, you only want users to run against all builds or just one, not a selection of builds. Otherwise you'd just use a standard multi-value parameter.
One way to do this is to return an extra row for all builds in your parameter dataset, e.g. something like:
select buildId as null, build = 'All'
union all
select buildId = build, build
from builds
I'm returning two columns here so we can pass a NULL value parameter but still have a user-friendly description to display in the report.
Set this up as your parameter dataset. In the report code you can then use the parameter to do something like:
select *
from builds
where (#build is null or #build = build)
Which will return all builds when #build is null and a specified build if #build is not null.
Would it be correct to simply change the where clause in the stored procedure to
Where [field] LIKE #variable
Then in SSRS under the Available Values have the "ALL" parameter value be % (the percent symbol) ?
Is there an error in logic here. It seems to have the desired result

How to passing date parameter using pentaho designer?

I have problem how to passing parameter date field database in report.
I have set the parameter like this :- X.createDate= ${datetim} in MySql.
I have also put the parameter setting in pentaho designer. When i run the report. the result not appear.
Below is Screenshot for parameter setting in report:-
Anybody know about this?.
You set a query on the parameter. If a parameter has a query, the query's results will be used as validation source. Any provided parameter value will be checked and only accepted if it is found in that result-set.
First: Mark the parameter as mandatory, so that you get informed if the reporting engine considers your parameter invalid.
Second: the date-picker does not actually indicate which values are valid or not. So if you indeed only want to select parameters based on the available dates in the database, I would recommend to NOT use the date-picker. Use a drop-down menu instead.

rs report design parametrized query for MySQL

I have a Mysql DB report with visual studio report server and is displaying correctly in report server.
but i want to do a parametrized query and after reading and searching i know the obdc driver cant pass # and i have to use '?' but after trying a lot i cant figured out how to implemented.
I have a #parameter which use a secodn dataset that query the db for usernames
i have my main dataset with the where (user = '?') and in the dataset parameter tab i try putting an expression with the select query for user and try use the actual parameter.
am a little lost here.
got it in my case..., use
where (usernames = ?)
in the query and in the parameters tab of the dataset use Parameter1 as name and in value match it with the created parameter in Parameters