SSIS connection string based on a variable - ssis

This is a follow up to my question: SSIS connection parameter based on parameter/variable
I now can see how to construct a variable from other variables, but it does not appear possible to then use that variable as the ConnectionString for the Connection. That appears to only allow variables.
How can I use my newly concatenated variable as the ConnectionString?

Ok, I can answer my own question now. It is a different location than if you want to use a parameter to set the ConnectionString.
Click on the Connection in Connect Manager and in the Properties window, expand Expressions. There you can click the ... to set it to a variable.

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.

SSIS: Read property from another component?

I created a simple SSIS job that exports a sql table to a text file. Since the filename's dynamic, I set the ConnectionString in the Flat File Connection Manager to an expression. So that works fine and the text file's generated based on the expression.
Now, I need to email that file. Is it possible to access the ConnectionString property from another component?
I understand that I can use variables, but I don't want to write code for this.
Thanks.
If you want to use an expression in multiple components you have to store it in a variable.
Create an SSIS variable, change the variable Evaluate As Expression property to True and write the expression in the variable Expression property.
Then in each component just use this variable as Expression
Or just write the same expression in each component

ssrs parameter values case sensitive

I have a link to a report (SSRS 2008 R2):
http://reportserver/pages/reportviewer.aspx?/folder1/report1&hostname=SERVER2
This report has a (drop-down list) parameter which contains hostnames.
The drop-down list has these entries:
server1
server2
server3
Problem is that sometimes the hostname is passed in uppercase (i.e. SERVER2) and thus the hostname is not selected in the drop-down list does not match the URL parameter. This is because SSRS is case-sensitive with regards to parameter passing.
I do not want the case-sensitivity.
I tried the setting on the Dataset (Dataset Properties - Options - Case sensitivity), but
that did not work.
Is it possible ?
The values in the drop-down box or the URL, I cannot modify.
Best solution would be case-insensitive parameter VALUE passing.
Use the LOWER() function in your SQL or the LCASE() function in SSRS. This function converts the string to all lowercase and if you do it to both sides then effectively case doesn't matter.
So either:
WHERE LOWER(fieldName) = LOWER(#parameter)
or
=LCASE(Fields!fieldName.Value) = LCASE(Parameters!selection.Value)
More info:
LOWER (Transact-SQL)
Useful Built-in functions of SSRS
Update
I slightly misunderstood your question. So you're accessing the report by manually generating the URL with the parameter value in it? This value needs to be passed in a consistent manner or this isn't going to work. SSRS is case sensitive and you can ensure that the available values in the report parameter are formatted consistently using the functions above.
But the generated URL also needs to be consistent. By doing it this way you are explicitly setting the value of the parameter and if it isn't a valid, available value it isn't going to work. The issue here isn't really SSRS it is the fact that the source of the URL does not generate the parameter value in a consistent way.
Fix your URL construction.

Parameter validation failed. It is not possible to provide valid values for all parameters. (rsParameterError) SSRS 2008

I am passing the parameter from aspx page to report server and getting this exception. Here is my code to set the report parameters.
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://zeeshankhatri-p/ReportServer_MSSQLSERVER2012");
ReportViewer1.ServerReport.ReportPath = "/DBAReporting/Clients";
ReportParameter p = new ReportParameter();
p.Name = "clientName";
p.Values.Add("Bank Alfalah");
ReportViewer1.ServerReport.SetParameters(p);
here are Parameter Properties:
Select Parameter Visibility = Internal
Allow Blank Value = checked
Allow null Value = checked
Available Values = None
Default Values = No default value
DataSet Properties:
Query:
Query Type = Stored Procedure
Parameters:
Parameter Name = #clientName
Parameter Value = [#clientName]
Can you please suggest what i did wrong in my case.?
There are a number of issues that may cause this:
The parameter Available Values query when run in this way contains no entries so you can't assign a valid value
The parameter is hidden and can't be assigned to in this way. Check report parameter settings on the server and adjust if needed.
You have made some changes to the parameter to the report in development that aren't being deployed to the report server. Note that certain parameter attributes, like default value, aren't overwritten when a report is re-deployed so that server settings aren't lost. Open the report settings and check report parameter settings on the server to make sure they match what you have in development.
It may be easier to delete the server report and deploy again to reset back to the development report settings.
You are also trying to pass a single parameter object to a function that allows you to pass many parameters.
SetParameters takes IEnumerable<ReportParameter> (usually a List), not just a single ReportParameterobject. You need to embed the parameter into an IEnumerable object. Here is a simple way to do it in one line of code:
ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { p });

Getting a "one or more parameters required to run the report have not been specified" error

I am building a report that I would like to accept two values from the user, feed those into a query, and find the data associated with those entries.
For example, if you had a list of employees, performance measures, and values associated with those; then the user would select an employee name / performance measure, and they would get the scoring information on that employee for that measure.
I have two parameters, each being populated from SQL queries getting a distinct list of employee names and measures, and a table below that just pulls up information based on ~ 'WHERE name = #Name AND measure = #Measure' but when I click 'Preview' to run the report locally I get the error: "one or more parameters required to run the report have not been specified"
I know the parameters are working properly because I can feed their values directly into a textbox and the values populate correctly. Also, if I change the query to just accept one parameter (i.e. WHERE measure = #Measure) the query works.
I'm confused as to why this error is occurring since I know my parameters are functioning and being populated properly.
I experienced this behavior in .NET 4.0 using Local Reports (in .rdlc files), when one of the parameter's values was containing an emtpy string. Although setting the parameter was correct:
report.SetParameters(
new List<ReportParameter> {
new ReportParameter("Title", Messages.Title),
new ReportParameter("SubTitle", Messages.Subtitle))
}
);
It worked only as long as both parameters actually contained some characters, otherwise the mentioned exception was thrown.
This error is caused when you either
A) the parameter is spelled wrong in the actual report. Meaning that the query is expecting #Name but the report is passing #Names (or some other spelling).
or
B) Is it possible you are attempting to run the report with a default value on the parameter of NULL for #Name but the stored procedure requires an actual value?
This might be happening if you are building the report in Visual Studio and gave the #Name parameter a default value of (null).
Try removing the default value or making sure you #Name parameter has an actual value, even if it's just ''.
I had similar issue. Issue happened when you use SharedDataSource with parameters that are to have null value. If you use same query in embeded data source, there is no problem.
Unlike embebed data source, you have to define if parameters used in query of shared data sources are allowed to have null value as highlighted in screenshot here. In my case, there are two parameters in query of shared data source, that can have null value.
So after setting them to allow null, problem fixed!
This caused me many hours of pain. Turns out that it's to do with using a shared dataset.
Embed the dataset within your report instead and it works fine.
For me, setting the value of the parameter makes problem. I don't know why, but the parameter value was not able to accept a string.Empty or null. So i just gave a " " as value solves the error.
Sample
ReportParameter[] parameters = new ReportParameter[4];
parameters[0] = new ReportParameter("Name", EName);
parameters[1] = new ReportParameter("ShiftName", CurrentShift);
parameters[2] = new ReportParameter("Date", LoginDate);
if(ValidateReportData())//some condition
{
parameters[3] = new ReportParameter("Date1", LoginDate);
}
else
{
//parameters[3] = new ReportParameter("Date1", string.Empty);//this makes exception while calling Render function.
parameters[3] = new ReportParameter("Date1", " ");//Solves the issue.
}
I was having the same problem, it is now sorted on sql server 2008 r2.
I know this is now an old question,
but just to help others:
It was very simple really, just making sure the spelling including the case is the same and the use of #.
I have a shared dataset called currentSpaceByDrive with the following code:
SELECT
[DRIVE]
,[Volume_Size_GB]
,[VolumeSpaceAvailable_GB]
,[VolumePercentAvailable]
FROM monitoring.dbo.currentSpaceByDrive(#ServerID)
I add the shared dataset currentSpaceByDrive to my report and I give it the same name.
when I right click on it, the one on my report, dataset properties, the parameter is #ServerID.
#ServerID value comes from another dataset, called the_servers (where the user selects a serverID)
I have a report parameter also called #ServerID that gets its value from the_servers and is used to feed the #ServerID parameter on currentSpaceByDrive.
Too many #ServerID, I understand, but if you do your own test based on this, you will get it done.
See the image attached.
hope this helps
marcelo
check DataSet In Report Server , I had Similar Problem , I was Editing Shared Dataset in Visual Studio , but it didn't work , after an hour of frustration I checked dataset in report server and I found out it Is not updating with changes I made in visual studio , I Delete it and Redeploy Dataset Again from visual studio . it works .
Actually I had to:
Delete the SubReport object from the report.
Drag new object from Toolbox
Setup the SubReport name and report
In Paramateres "Add", and choose each parameter, and related value.
Then is works for me.
I think I have same issue my Parameter Supervisor is blank when I choose "Select All" which causes the error "One or more parameters were not specified for the subreport", but if I select a few supervisor name then the sub-report appears. It is puzzling because the Manager parameter value shows all value when "Select All" is checked, but it is not working on my Supervisor parameter. Note that Supervisor parameter is dependent on manager parameter.
I'm using shared DataSets for several reports, and the root cause of this issue was not mapping the input parameters from the report itself to the parameters of the shared dataset.
To fix, I navigated to the "Report Data" panel, opened the dataset (which is really linking to a shared dataset), clicked the "Parameter" tab, and then mapped the report parameters to the parameters of the shared dataset.