问题
When I select the "!" ("Run") button on the Data tab of the design surface in a BIDS project, it prompts me for the parameters the Stored Procedure I have selected needs:
Once these are supplied, and I click the Okay button, I see the data returned in a grid within the Data tab.
Using the same Stored Procedure (but not selected exlicitly - apparently the project knows which one to use based on what is selected in the Data tab) on the Preview tab, instead of prompting me for the Stored Procedure's parameters with a dialog box, it presents controls (two DateTime pickers and a dropdown list populated with the appropriate options):
Yet, when I enter the same exact values that work on the Data tab in the Preview tab (selecting the value I entered for "Unit" from the dropdown list) and then select the "View Report" button, I get:
An error occurred during local report processing. An error has occurred during report processing. Query execution failed for data set 'PriceVarianceSP'. Procedure or function 'priceAndUsageVariance' expects parameter '@Unit', which was not supplied.
It's true that priceAndUsageVariance expects @Unit:
CREATE Procedure [dbo].[priceAndUsageVariance]
@Unit varchar(25),
@BegDate datetime,
@EndDate datetime
AS . . .
...but it also expects two other values - all three of which HAVE been supplied. Is it only complaining about a supposedly missing "@Unit" value because that's the first one in the list, and it would complain about @BegDate and @EndDate missing, too, if it considered @Unit supplied, or the params were ordered differently?
Attempting to run (execute <- and I do feel like executing it, sometimes!) the report in SSRS (online) throws the same err msg as the Preview tab.
So how can I get this to work? Does something in the Stored Procedure need to change, or is there some change I need to make to my report file, or...???
UDPATE
If the .rdl may provide a clue as to what is here haywire, here it is, in all its radiant glory:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="PlatypusData">
<rd:DataSourceID>875e488f-a3fc-4066-befb-5b85a938f58d</rd:DataSourceID>
<DataSourceReference>PlatypusData</DataSourceReference>
</DataSource>
</DataSources>
<InteractiveHeight>11in</InteractiveHeight>
<ReportParameters>
<ReportParameter Name="BegDate">
<DataType>DateTime</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>Begin Date</Prompt>
</ReportParameter>
<ReportParameter Name="EndDate">
<DataType>DateTime</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>End Date</Prompt>
</ReportParameter>
<ReportParameter Name="Unit">
<DataType>String</DataType>
<AllowBlank>true</AllowBlank>
<Prompt>Unit</Prompt>
<ValidValues>
<DataSetReference>
<DataSetName>UnitsQuery</DataSetName>
<ValueField>Unit</ValueField>
<LabelField>Unit</LabelField>
</DataSetReference>
</ValidValues>
</ReportParameter>
</ReportParameters>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<RightMargin>1in</RightMargin>
<LeftMargin>1in</LeftMargin>
<BottomMargin>1in</BottomMargin>
<rd:ReportID>bad7a923-1452-4e00-9cc3-1f437ad70ef6</rd:ReportID>
<DataSets>
<DataSet Name="PriceVarianceSP">
<Query>
<DataSourceName>PlatypusData</DataSourceName>
<CommandType>StoredProcedure</CommandType>
<CommandText>priceAndUsageVariance</CommandText>
</Query>
</DataSet>
<DataSet Name="UnitsQuery">
<Fields>
<Field Name="Unit">
<DataField>Unit</DataField>
</Field>
</Fields>
<Query>
<DataSourceName>PlatypusData</DataSourceName>
<CommandText>select distinct Unit from masterunits order by unit</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
</DataSet>
</DataSets>
<Width>33in</Width>
<Body>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<Style>
<Color>SteelBlue</Color>
<FontFamily>Tahoma</FontFamily>
<FontSize>20pt</FontSize>
<FontWeight>700</FontWeight>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
<CanGrow>true</CanGrow>
<Height>0.36in</Height>
<Value>PriceAndUsageVarianceReport</Value>
</Textbox>
</ReportItems>
<Height>2.625in</Height>
</Body>
<Language>en-US</Language>
<TopMargin>1in</TopMargin>
</Report>
UPDATE 2
This is what solved the dilemma:
On the Data tab of the design surface, select the ellipsis dots ("Edit Selected Dataset").
In the Dataset dialog, choose the Parameters tab.
Set the values like so:
(Once you enter a Parameter name beneath the "Name" column, the "Value" column populates with available assignments from which you can choose).
回答1:
When parameter values are not supplied, you will only get an error message about the first one, not about all of them.
Sounds to me that you need to go into the Parameters tab in your DataSet properties, and map the report parameters to the dataset parameters.
来源:https://stackoverflow.com/questions/34908470/what-is-the-difference-between-how-the-data-and-preview-data-generation-work