Dynamic ConnectionString in Connection Manager (OLE DB) - sql-server-2008

I have a local database table that contains 50+ external data sources from which I can build a connection string. I am currently trying to setup SSIS to dynamically build connection strings from this table and pass them to the connection manager. I have successfully set a variable and assigned this variable to the ConnectionString expression property in Connection Manager.
I then use an OLE DB source object to copy a table from this source to our local database. The problem is that if the connection string is not set at design time I get validation errors for the OLE DB object.
If I manually set the connection string property it works fine, but that defeats the perpose of creating the dynamic connectionstring variable.
The idea here is to have the dynamic partion detect what machine it is running from and build the proper string (DEV, UAT, QA). I also do not want these connection strings in a dtsConfig file.
I took a look at this: http://www.simple-talk.com/sql/ssis/working-with-property-expressions-in-sql-server-integration-services/, but it does not have any solution for my situation.

I just found the solution after reading the first line of that error "Package Validation Error" I went to the package properties and changed DelayValidation to True.
I guess asking questions here really does help you find your own solution.

Related

connection to external MySQL in VB

I am able to create a connection string to query the database from an external network however am unable to create a connection via new data source and therefore a dataset in order to populate a data grid view using the external information.
I have made it so that if pc name = name of dev pc it uses local server name to connect, otherwise it uses external IP.
Is there a way to create a connection for the external connection from the dev computer as its not possible to test connection and therefore gets error that its unable to connect to specified MySQL host
When inputting data into a data grid view a connection needs to be made by assigning that grid view a source. These sources come from the datasets created from the connection string by going to project, add new data source. Because the dataset needs to be accessible externally I need to create a new connection string through add new data source. Because the dev computer and database are on the same computer I cant create the connection string using that method and therefore cant create the dataset to populate the data grid view.
Thanks in advance
You are trying to solve the wrong problem here. Just create your data source to the local database normally. The connection string will be stored in the config file. When you deploy the application, you deploy the config file as well and you simply modify the connection string in it. How do you think developers create applications for customers that use completely different databases?

SSIS For Each Loop crashes the flat file connection

I created a simple SSIS package to import a flat file (.txt) into a database table. Tested that and it works perfectly. Since I have several files to import, I added a foreach loop to go through all the files, added the variables as recommended in several examples found on the net but now my flat file connection manager returns an error of "A valid file name must be selected." and the package will not run. I have so far been unsuccessful in finding the solution for this issue and would appreciate any suggestions by the SSIS gurus of this forum. Many thanks in advance!
Here is what I have in the way of variables:
SourceFileFolder which is the path to the folder that contains the files
FileName a string containing one of the names of the files I am seeking to import
SourceFilePath which is an expression driven variable that incorporates the previous two variables concatenated together. I can click "Evaluate Expression" and copy and paste it into windows explorer and open the file
ArchivePath which is an expression driven variable that creates the path to archive the file to once it is processed.
As the message says this is related to your connection manager not gathering the connection string. This can be handled using the following:
First of all clear the expression on the SourceFilePath variable.
With your Foreach Loop Container, set it up as follows:
This will use your variable SourceFileFolder as the Folder, you could also just hardcode the folder name C:\ for instance. Also make sure your folder is qualified correctly, I.E. make sure it finishes with a slash C: won't work but C:\ will work.
Next you need to map the fully qualified name to your other variable SourceFilePath
This should now store the full name of the file the loop has found into the SourceFilePath variable. For Instance C:\File.txt, you can now use this as a connection string expression on your file connection manager.
Under the properties of the connection manager make sure the expression is set to ConnectionString and then use the SourceFileName variable.
ALSO MAKE SURE DELAY VALIDATION IS SET TO TRUE
This hopefully should mean you can loop through the files.

Run SSIS Package with 2 Different Configurations

We have a SSIS job called ExportData and it accepts the 'ExportType' Parameter. The ExportType parameter can be 'schedule' or 'unschedule'.
I created the Variable called '#ExportType' and created the SSIS Configuration and expose the variable in the Configuration file and called it 'ScheduleConfig'. I copied that file and change the value to 'unschedule' and called it 'UnscheduleConfig'.
I created the SSIS Job in the SQL Server 2008 and set up 2 steps for both 'Schedule' and 'Unschedule'. I attached the correct config file for each Step. But whichever step I run, it always execute 'Schedule'. I am sure and double checked the Config files and Steps.
How can I run 2 different jobs with 2 different configuration files?
I did try by using the SetValues method and it doesn't work too.
I suggest you not store #ExportType in an SSIS Configuration. You can override the value from the DTEXEC command line by adding a SET switch similar to:
/SET "\Package.Variables[ExportType].Properties[Value]";Schedule
You can use the same PackagePath above to override this variable value in the SQL Agent Integration Services Job Step Type on the Set Values tab.
Hope this helps,
Andy
If I understand your requirements correctly. here is a sample package created in SSIS 2008 R2 and does what you are looking for. The sample uses a single package, which is executed under two different SQL agent job steps and both the steps use a different copies of the same configuration file. The configuration files hold different values for the variable used inside the package.
Created a sample SSIS package named SO_10177578. Within the package, created a package variable named ExportType of data type String. Also, placed the Execute SQL Task on the Control Flow tab. This task will help to identify the value being passed to the variable ExportType.
Added the OLE DB connection to a sample database and named the connection as SQLServer. I chose to use SQL Server authentication for this connection manager.
Within the SQL database, created a table named dbo.ExportData with the following strucutre. Id column is a identity column.
The table doesn't contain any data to begin with. This table will be populated with data when the package is executed.
On the SSIS package, clicked on the SSIS menu --> selected Package Configuration option. On the Package Configurations Organizer dialog, selected the Enable package configurations checkbox and clicked on the Add button. Created a new package configuration of the type XML Configuration file. Selected a path to store the file.
Added the Value property of the variable ExportType and the ConnectionString property of the connection manager SQLServer to the configuration file.
On the Execute SQL Task, selected the Connection to be SQLServer and set the SQLStatement property to INSERT INTO dbo.ExportData (PackageName, ExportTypeValue) VALUES (?, ?)
Configured both the parameters to the appropriate variables available on the package. Now the package is ready for deployment.
On the database server's SQL Agent node, created a new SQL job named Test_ExportData. Owner field information is removed to hide sensitive information.
On the SQL job's Steps page, created two steps named Step_01 and Step_02.
Step 1 is configured as below with the package being stored in the path c:\temp\SO_10177578.dtsx.
Copied the package configuration file created using the package and changed the value for the variable ExportType to Schedule. Named the configuration file as ScheduleConfig.dtsConfig. Screenshot shows only part of the configuration file to hide sensitive connection string information.
In step 1 of the job, referred the newly created package configuration file from the path c:\temp\Test\ScheduleConfig.dtsConfig.
Step 2 is configured as below and it uses the same package stored in the path c:\temp\SO_10177578.dtsx as used by step 1.
Copied the package configuration file created using the package and changed the value for the variable ExportType to Unschedule. Named the configuration file as UnscheduleConfig.dtsConfig. Screenshot shows only part of the configuration file to hide sensitive connection string information.
In step 2 of the job, referred the newly created package configuration file from the path c:\temp\Test\UnscheduleConfig.dtsConfig.
Now, both the steps are configured. Executed the new SQL agent job.
Queried the table ExportData. You can notice that the package was executed twice and each execution in the SQL agent job's steps used the appropriate configuration files specified on the steps.
Hope that helps.
you cant do that. The SSIS wont read the new configuration.
You need to call the package twice, one time with config file A and one time with config file B. On each config file you will have the #ExportType variable set to 'schedule' and 'unschedule'.
You can only set a parameter once. Even if you use DTEXEC with the /Config option for example you CANT overwrite a parameter that is already set

SSRS Dynamically change Datasource connection String

I want to modify the connection String of a Shared Data Source on a report Server. the reason is, every week we deploy new data on the server, so I am planning to deploy new database, test it and modify the datasource so that it than connect to new database, then remove the old database.
Can anyone help me in the regards.
I tried to use this post: Updating Shared data source connection string programmatically
but I can not create ReportingService2005 object as dll is missing to which this object points.
Thanks
ReportingServices2005 is not a dll, it's a webservice
The URL is formatted as below for most 2005 instances:
https://<<Report Server Name>>/ReportServer/ReportService2005.asmx
If you add the web reference the solution you have should work
An alternative to creating a custom application to do this is to use the rs.exe utility to execute the code as a script.
Scripting with the rs Utility and the Web Service

How to change the flatfile connection manager "file name" value in SSIS package?

I have an ssis package...which read data from fixed-column-width text file into DB table.
And I am modifying an existing ssis package.
I have a flat file source...and flat file cnnection. When I try to edit the flat file connection...using "flat file connection manager editor"..., under "general" part...even if I select different filename..it's not getting reflected.
OR...select the properties window of "Flat File Connection" - once I change connection string and click "save" of visual studio...it rollback
Help me please.
Pulling a useful comment into an answer...
It's possible that that Connection string (the file path, name) is set from an expression/user or project parameter.
To check, right-click the flat-file connection manager and go to Properties, then check Expressions to see if the ConnectionString is set from a variable such as #[User::MyFileConnectionString]
That would cause this behavior of it seemingly "un-doing" after you change it manually.
Is it possible you don't have access to the package itself? Right clicking on the file icon in the Connection Manager below and selecting 'Rename' and then renaming it right there and then saving the package should work.