开发者

Executing SSIS package from c#

I have to create a Windows Form application which would modify the connection sring values present in dts config file and then execute the package with this updated dts config file.

Even if I am adding following line of code,it is not taking the updated confi开发者_JAVA百科g file.

string packagePath = ConfigurationSettings.AppSettings["packagepath"].ToString();
Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
 Package package = app.LoadPackage(packagePath, null);
 package.ImportConfigurationFile(configPath);
 DTSExecResult dtsResult = package.Execute();

Please help how to execute the package with modified dts config.


You need to read the dtsConfig file, which is an XML file, using the .NET XMLDocument object and then modify the appropriate node containing the connection string with the new value.

Example in the following MSDN forum shows how this can be done:

Setting SSIS package properties programmatically

Personally, I use database table to store package configuration values. I feel that is much easier to maintain than the xml configuration files (dtsconfig).


Check this thread out:

SSIS how to set connection string dynamically from a config file

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜