VS Problems with Dateadd function using parameters in a query - visual-studio

I am creating a report in MS Visual Studio 2008 epxress. The dataset should be limited using parameters. I want the users to have the ability to choose a starting date and then name the number of years into the future they want to see the data.
I created 3 parameters
1. fromdate (Type:Date/Time; visible): This is where they choose a date
2. futureyears (Type: Integer; internal): This is where they should write the number of years into the future
3. todate (Type: Date/Time; internal): This is an internal parameter with the following function as the default value:
=dateadd(DateInterval.Year,Parameters!futureyears.Value,Parameters!fromdate.Value).
fromdate and todate are then used in the query of the dataset to limit the data.
The following error appears when I try to preview this:
"The DefaultValue expression for the report parameter 'todate' contains an error: The expression that references the parameter 'futureyears' does not exist in the parameters collection. Letters in the names of parameters must be use in the correct case"
The thing is: The parameter "futureyears" does exist, when I write the function for the default value of todate, I choose it from the parameters section. so it is there.
I tried to run this report without the futureyears parameter and typed in a random number in the dateadd function. Without the parameter in question, the report runs fine. the problem must be the parameter "futureyears", but I don't know where the problem is. Thank you for your help.

I just figured out the answer myself. Leaving this here in case anyone has a similar problem.
In the parameters folder, the "futureyears" parameter was listed UNDER the "todate" parameter.
All I needed to do for it to work was shift the futureyears parameter ABOVE the todate parameter. Now the report runs fine.

Related

how to pass the parameter 08-2019 in birt report

how to pass the parameter 08-2019 in birt report I need to pass this month and year parameter which I marked
You do that with query parameters. You first need to exchange the date string in the query with questions marks (?). For your example, this will be 5 question marks.
Edit the Dataset, change the query, and then click Parameters on the left. Important: you need to add a parameter for each single question mark even if they all relate to the same value. Parameters will be added to your query in order of definition. If you have more or less parameters than question marks in your query, an exception will be raised. So keep these synchronized.
As you do have a specific date format, do use String as parameter type. You can use a report parameter as a reference and pass that string dynamically (which is most likely what you want).

IIF Statement in TablixFilter issue

I'm trying to filter a matrix in my report. I have names of 4 drivers and I want the Matrix5 to show the name of a default driver in case SELECT ALL is checked in filter. Otherwise I want the matrix to show whoever is checked.
I set an expression at matrix filter as;
=IIF(Parameters!Sofor.Count=4,"abcdef",Parameters!Sofor.Value)
-abcdef is the name of the default driver for the tablix
-Sofor is the driver name parameter and has 4 total possible name options, 5 if we consider SELECT ALL too.
It works well if I check SELECT ALL but stops working if I select only one option.
Error I'm getting is as follow;
"The processing of FilterExpression for the tablix "Tablix5" cannot be performed. Cannot compare data of types System.String and System.Object[]. Please check the data type returned by the FilterExpression"
Though the error sounds pretty self explanatory I still can't understand what I'm doing wrong. Any help please?
Parameters!Sofor.Value is an array of values (the object) because its a multi-select parameter. (what happens when the user chooses 2 drivers?)
Try
=IIF(Parameters!Sofor.Count=4,"abcdef",Parameters!Sofor.Value(0))

Error tyring to add a parameter in MS Visual Studio

I am trying to create a report in MS Visual Studio and use the DateClosed as a parameter so that a user can select on 'DateClosed'. The error I am getting says:
Error Message: Conversion failed when converting date and/or time from character string.
The select satement is below is based on a view that I had to convert a string (DateClosed) to a datatime data type.
SELECT GrantNumber, GrantAmount, GrantDate, NatureOfGrant, SpecialInstructions, FullName, GMP, GrantType, Name, DateClosed
FROM V_WSF_GrantMakingPartnersGrants
ORDER BY DateClosed DESC
I am really confused because the 'ClosedDate' above is returning the value as a datetime data type. I can't cast it again, because it already sees it as a date. This is making no sense to me.
Can anyone tell me how to add the parameter into MS Visual Studio?
It's not clear where you are getting the data from - SQL Server or Oracle? So you want to pass the date? Ie, you enter 02/02/2012 and then click to generate report?
If you are passing to Oracle, you might have to use the sql function TO_DATE(xxxx). The same thing may apply to SQL Server but that is not an area I'm not familiar with. Therefore:
..order by DateClosed may have to read like this:
to_date(DateClosed, 'yyyy/mm/dd')
The 2nd parameter - must match the date format that you are sending in...
I hope this helps...
I think you should use the dateTime.formate to specify the format type on the dataBase..
like "YYYY-MM-dd". make sure the format is the same date format you are using on your DataBase string date.
I think this will solve your problem.

How to put a parameter into an query in SSRS 2008 R2 connected to an Oracle Database 11g

Putting a parameter into the query gets the following error:
"ORA-01036: illegal variable name/number"
The query is:
select * from t_accounts where account_number = #ReportParamter1
Without the where clause, the query runs fine
Any ideas?
thanx!
Abraham
Oracle wants its bound parameters to be denoted with colons, not # signs.
So you want
...where account_number = :ReportParamter1
O. Jones highlighted the root but didn't go into as much detail as I needed to address this same issue/question. I had created the parameter in Visual Studio and as noted it has the '#' in the format of the parameter so when applied to the Dataset I got the error message. Unfortunately in the construct of the parameter in VS (I'm using 12) there isn't anything in the various options that allows designating a : in place of the #. What I discovered was after manually adding the parameter to my query in the Dataset, I then found it listed in the parameters area of the Dataset Properties - the parameter entered in query was set to the parameter made in VS. I removed the original and preview processed without issue.

Using parameters in reports for VIsual Studio 2008

This is my first attempt to create a Visual Studio 2008 report using parameters. I have created the dataset and the report. If I run it with a hard-coded filter on a column the report runs fine. When I change the filter to '?' I keep getting this error:
No overload for method 'Fill' takes '1' argument
Obviously I am missing some way to connect the parameter on the dataset to a report parameter. I have defined a report parameter using the Report/Report Parameter screen. But how does that report parameter get tied to the dataset table parameter? Is there a special naming convention for the parameter?
I have Googled this a half dozen times and read the msdn documentation but the examples all seem to use a different approach (like creating a SQL query rather then a table based dataset) or entering the parameter name as "=Parameters!name.value" but I can't figure out where to do that. One msdn example suggestted I needed to create some C# code using a SetParameters() method to make the connection. Is that how it is done?
If anyone can recommend a good walk-through I'd appreciate it.
Edit:
After more reading it appears I don't need report parameters at all. I am simply trying to add a parameter to the database query. So I would create a text box on the form, get the user's input, then apply that parameter programmatically to the fill() argument list. The report parameter on the other hand is an ad-hoc value generally entered by a user that you want to appear on the report. But there is no relationship between report parameters and query/dataset parameters. Is that correct?
My last assumption appears to be correct. After 30 years in the industry my bias is to assume a report parameter actually filters the SQL data using the given parameter. This is not the case with .rdlc files used by Report Viewer. These report parameters have nothing to do with fetching data. Sounds like this was a design decision on Microsoft's part to completely separate the display of data from the fetching of data, hence, Report Viewer has no knowledge of how data may be fetched. Best way for me to conceptualize this dichotomy is to think of Report Parameters more as Report Labels, quite distinct from the dataset query parameters.

Resources