TelerikReport send null as parameter to StoredProcedure - telerik

I want to use Telerik report in project, and want to use a stored-Procedure as data source. So, I should make a report in Telerik Report Designer in first step (my problem), and then use it in my Asp.net project.
I exactly used the (wizard) approach to make data source and parameters, mentioned in Telerik documentations, but there is a problem:
The report passes only the default parameter defined on design time, and when I change the parameter value in preview mode, it doesn't be passed to SP. If I set no default value for my parameters, the SP would be call by null values, always. It seems there is no mapping between input textboxes and the parameters are be sent to SP.
Is there anybody had the same experience, that can help me?
UPDATE:
What I did:
create new blank report in Telerik Report Designer R1 2017
From Data tab, Select SQL Data Source,select the proper SP from an Existing Data connection, leave the parameters default value empty and then execute...and finish.
In Report Explorer window, right click on Parameters, and add new parameter with the name and data type of stored procedure parameter. Change it's visibility to true, without any value.
From Home tab, select the preview and checked the SQL Profiler for db calls tracking. The Sp is called by null values at first time, but even when I change the parameter value in preview mode, again the SP is called by null parameter values.

In design time, after selecting your SP as data source, you will see the Configure Data Source Parameters.
In this window, you see your SP's parameters with value types. In Value column, click each row and select <New Report Parameter> and then select the parameter. The value will be change to proper value, for example:
= <Parameters.CustomerNumber.Value>
And this will work correctly. The problem was the 3th. step in question above. (adding the parameters, manually)

Related

SSRS reports dynamics crm have current record id used as parameter

Hi for my ssrs report In dynamics crm I require that when the report is ran against a certain record, the records passes the record id so that only the relevant results are displayed.
How is this possible ? Steps provided will be great also
Reports are created using SQL.
Run against campaign entity
SSRS reports for CRM have special parameters that enable this for you. To filter by selected records (or the current record you have open) you can utilise a hidden parameter called "CRM_Filtered[Entity]" where entity is the relevant entity you are linking the report to.
In your case, i.e. for the campaign entity, this hidden parameter will be called CRM_FilteredCampaign. For a SQL report this will be a text parameter and will be set to something like this (set by CRM when you run the report)
select campaign0.* from FilteredCampaign as "campaign0"
I do not have a report to hand to check exactly what the SQL will contain, so it might not be exact. But you get the idea. There are several ways to embed this in your report, but you could do so in a rudimentary fashion like this in a dataset:
declare #sql as nVarchar(max)
set #sql = 'SELECT c.campaignid FROM (' + #CRM_FilteredCampaign + ') as c'
exec(#sql)
Expanding on this, i.e. rather than executing text SQL in your main dataset, you can instead simplify the usage by creating a dataset/parameter combo based off the text. In effect, convert the SQL text to a list of values instead.
So add the above SQL to its own DataSet (for this example called DS_FilteredCampaign).
Once you have created DS_FilteredCampaign make sure you click on the Refresh Fields button. Type in the following instead of <null> for the parameter value:
select c.* from FilteredCampaign as c
Once that comes back click on Ok to save the DataSet.
Next, create another hidden text parameter (e.g. Int_FilteredCampaign) and tell it to get its default value from a DataSet (not its available values, its default value). Point the values at DS_FilteredCampaign, and you should be able to select campaignid as its value field. This in effect makes the parameter an array of Ids you can reference in your main DataSet
Now it's much more usable as you can reference it in your SQL something like this in your main DataSet:
select c.*
from FilteredCampaign c
inner join ActivityPointer ap on ...
inner join FilteredAccount a on ...
where c.campaignid in (#Int_FilteredCampaign)
The important piece being where c.campaignid in (#Int_FilteredCampaign)
Summary Steps:
You have a main DataSet called something like dsMain
Create a new parameter called CRM_FiltetedCampaign
Create a DataSet (DS_FilteredCampaign) that executes the SQL passed into CRM_FilteredCampaign
Refresh Fields on the data set to get the campaignid field
Create a text parameter (Int_FilteredCampaign) that retrieves its default value using the new dataset (DS_FilteredCampaign) using campaignid for the value
Reference this new parameter in you dsMain dataset

How do I set an SSRS Parameter that doesn't have a value to something else?

I have an SSRs Report with a parameter that gets information from SQL. If it hasn't found anything, at the moment it is just empty. Is there anyway to set it such that if it's empty it will return a different value, say "Please Extend Date Ranges" and disable the parameter?
If you using it to fill it using the SQL and using it for only internal purposes then there is option to make the parameter internal and it will be hidden and it will does not prompt the user.
Make a change to the stored procedure or query that populates the parameter. Include some logic so that if no results are returned by the query you are using now, it adds a row with the default label you want.
But no, you can't disable the parameter dynamically, I don't believe.

Best practice for single-valued result in SSRS 2012

I'm new to Reporting Services and using SQL Server Data Tools (Visual Studio 2012). I want to add an item that will display a single value - in this case, the result of a stored procedure call. The value would probably be displayed in the report header.
I've looked at the Tablix data parts that can be added to the report: table, list, and matrix. Not sure which of them, if any, would be appropriate. I could add a parameter item, but it seems that these function as user input choices.
I also looked at a read-only text box, but don't see how to populate it with a query result.
What is the accepted method of adding a single-value result to a report?
If this is to be displayed in the page header, your only option is a textbox; you can't add tablix type parts to page headers/footers.
The textbox expression would be something like:
=First(Fields!MyValue.Value, "DataSet1")
By using an aggregate expression like this you can make sure only one value is returned (even though you might always have only one) and you can also specify the aggregate's Scope; in this case the DataSet you want to query.
If this was going in the report body I would still recommend the same approach, though I wouldn't go so far as to call it best practise, any would work so it's really personal taste.
However, if you had multiple fields returned by the SP but still only one row, in that case I would recommend a table style tablix with one header-level row; easiest to maintain and layout.

Report parameters always using design time values

How do I get the report to use a design-time set value on first run, and then use whatever the user inputs for subsequent 'refreshes'?
I'm using .Net 4 and Telerik Q1 2013 Reporting controls.
I've created a report that has a StartDate and EndDate parameter, which is passed to a SQL query and returns relevant data.
To make it easier for the users to just open and run the report with minimal effort, the StartDate and EndDate have a default value, being set as the first and last day of the current month respectively.
This works great. However, if the user changes these values after the report is loaded, and tries to run the report for say the first to last day of the previous month, the query does not use the user-entered values. Instead it always uses the expression for what is supposed to be the default value.
The way I set the default value is by opening the ReportParameter Collection Editor (right-click in the report, click Report Parameters), and set the Value property of the parameters.
The StartDate is set to:
=StartOfCurrentMonth()
and EndDate is set to
=EndOfCurrentMonth()
Any help would be greatly appreciated!
Stephen,
What you've outlined here works for me, are you maybe not running the service pack? I set the Value property in the ReportParameter Collection editor to both StartDate and EndDate as:
='3/1/2013'
The preview of the Report runs immediately with the default values. I am able to change the values and preview the report fine.
I created a Windows Forms application that creates an instance of the report. When the report first renders, it renders with the default values and I am also able to change the values in the ReportViewer as an end user and re-render the report with no issues.
TopPageViews report = new TopPageViews();
InstanceReportSource reportSource = new InstanceReportSource();
reportSource.ReportDocument = report;
this.reportViewer1.ReportSource = reportSource;
this.reportViewer1.RefreshReport();

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