[转]SSIS ConnectionManager.ConnectionString Property
Gets or sets the connection string used to establish a connection to a data source.
Namespace: Microsoft.SqlServer.Dts.Runtime
Assembly: Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)
The format and contents of the connection string depend on the data provider, the data source, and the type of connection manager that is being created. To view a sample connection string, in SQL Server Data Tools, create a package, and then create a connection manager of the appropriate type within that package. Next, in the Properties window, examine the ConnectionString property of the connection manager that you just created.
The following code example adds an OLE DB connection manager, and then sets the connection manager name and connection string properties.
// Add the OLE DB connection manager.
ConnectionManager adventureWorks = package.Connections.Add("OLEDB");
// Set stock properties.
adventureWorks.Name = "OLEDBConnection";
adventureWorks.ConnectionString = @"Provider=SQLNCLI10;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=AdventureWorks;Data Source=(local);Auto Translate=False;";
For an XML connection string, the connection string value is formatted similar to the following:
String myConnString = @"C:\Program Files\Microsoft SQL Server\orders.xml";
Whereas for an OLE DB connection, the connection string contains values similar to the following connection string:
String myConnString = "Server=MYSERVER;Provider=SQLOLEDB.1;Pwd= xxxxxxx;User ID= xxxxx;Initial Catalog=mySource;OLE DB Services=-2";
And an ODBC connection string may look similar to the following:
String myConnString = "DSN=LocalServer;DATABASE=MySource;PWD=xxxxxxx;UID=xxxxx";
In the properties dialog box of a connection in the SSIS Designer, this value appears as the Connection String property.
For a list of all connection managers included with the product, see Integration Services (SSIS) Connections.
The following code example creates a FileSystemTask as an Executable in a package. The FileSystemTask copies a test folder that contains two subfolders and a .txt file, to another folder. The source and destinations are existing folders. Therefore, theIsDestinationPathVariable and IsSourcePathVariable are set to false, and the Destination and Source properties are set to reference two FILE connection managers that have been created and have had their connection strings set to reference Stringscontaining the paths.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask; namespace FileSystemTask_API
{
class Program
{
static void Main(string[] args)
{
String sourceDir = @"C:\TestFolder";
String destDir = @"C:\MyNewTestFolder"; Package pkg = new Package();
Executable exec1 = pkg.Executables.Add("STOCK:FileSystemTask");
TaskHost th = exec1 as TaskHost; // Show how to set properties using the TaskHost
// Properties. Set the properties to copy an existing
// folder, which contains two subfolders and a .txt file,
// to another existing folder on the C:\ drive. // The source or destination files are not in a variable,
// so set IsSourcePathVariable and
// IsDestinationPathVariable to false.
th.Properties["IsSourcePathVariable"].SetValue(th, false);
th.Properties["IsDestinationPathVariable"].SetValue(th, false); // Create the File connection manager for the source.
ConnectionManager cm = pkg.Connections.Add("FILE");
cm.Name = "The FILE connection manager";
cm.ConnectionString = sourceDir;
cm.Properties["FileUsageType"].SetValue(cm, DTSFileConnectionUsageType.FolderExists); // Create the File connection manager for the destination.
ConnectionManager cmdest = pkg.Connections.Add("FILE");
cmdest.Name = "The destination FILE connection manager";
cmdest.ConnectionString = destDir;
cmdest.Properties["FileUsageType"].SetValue(cmdest, DTSFileConnectionUsageType.FolderExists); // Set the source property and destination properties
// for the task.
th.Properties["Source"].SetValue(th, cm.Name);
th.Properties["Destination"].SetValue(th, cmdest.Name); // The operation to perform is to copy all the files and
// subfolders in a folder.
// Do not overwrite the destination information
// if it exists.
th.Properties["Operation"].SetValue(th, DTSFileSystemOperation.CopyDirectory);
th.Properties["OperationName"].SetValue(th, "Copy TestFolder");
th.Properties["OverwriteDestinationFile"].SetValue(th, false); // Set the attribute of the folder to be read-only.
th.Properties["Attributes"].SetValue(th, DTSFileSystemAttributes.ReadOnly);
// Multiple attributes can be set. The next line of code,
// commented out, shows how to do that.
//th.Properties["Attributes"].SetValue(th, DTSFileSystemAttributes.ReadOnly | DTSFileSystemAttributes.Hidden); // Run the task and copy the folder.
DTSExecResult result = pkg.Execute();
}
}
}
[转]SSIS ConnectionManager.ConnectionString Property的更多相关文章
- How to attach multiple files in the Send Mail Task in SSIS
Let’s say you need to create a SSIS package that creates 2 files and emails the files to someone. Yo ...
- MySQL+Amoeba实现数据库主从复制和读写分离
MySQL读写分离是在主从复制的基础上进一步通过在master上执行写操作,在slave上执行读操作来实现的.通过主从复制,master上的数据改动能够同步到slave上,从而保持了数据的一致性.实现 ...
- OLE DB Command transformation 用法
OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used ...
- 使用http.sys,让delphi 的多层服务飞起来
核心提示:一直以来,delphi 的网络通讯层都是以indy 为主,虽然indy 的功能非常多,涉及到网络服务的各个方面,但是对于大多数多层服务来说,就是需要一个快速.稳定.高效的传输层.Delphi ...
- Amoeba for MySQL读写分离配置
一. 安装和运行Amoeba 1. Amoeba for MySQL 架构: 2. 验证Java的安装Amoeba框架是基于Java SE1.5开发的,建议使用Java SE1.5以上的版本 ...
- Amoeba+Mysql实现数据库读写分离
一.Amoeba 是什么 Amoeba(变形虫)项目,专注 分布式数据库 proxy 开发.座落与Client.DB Server(s)之间.对客户端透明.具有负载均衡.高可用性.sql过滤.读写分离 ...
- C#中使用ADOMD.NET查询多维数据集
ADOMD.NET 是用于与 Microsoft SQL Server Analysis Services 进行通信的 Microsoft .NET Framework 数据访问接口. ADOMD.N ...
- 使用 TFDConnection 的 pooled 连接池
从开始看到这个属性,就一直认为他可以提供一个连接池管理功能, 苦于文档资料太少, 甚至在帮助中对该属性的使用都没有任何介绍,如果你搜索百度,也会发现基本没资料. 最后终于在其官方网站看到了其完整相关的 ...
- (spring-第5回【IoC基础篇】)spring容器从加载配置文件到实例化bean的内部工作机制
前面讲过,spring的生命周期为:实例化前奏-->实例化-->实例化后期-->初始化前期-->初始化-->初始化后期-->bean的具体调用-->销毁前-- ...
随机推荐
- IntelliJ IDEA 启动方法
IntelliJ IDEA cd idea-IU-145.1617.8/bin && ./idea.sh
- [转载] login shell和non-login shell
原文地址:这里. 在linux中我们知道当你输入一条命令的时候,命令的查找是根据环境变量PATH来查找的,如果想知道一个命令的源文件存放在什么地方可以用which或whereis指令.那么PATH变量 ...
- Linux文件系统中/tmp的临时文件清理说明
https://www.cnblogs.com/MonkeyAC/articles/3631401.html
- 网易2019校招C++研发工程师笔试编程题
丰收? (忘了题目了QAQ) 题目描述: 又到了丰收的季节,恰逢小易去牛牛的果园里游玩. 牛午常说他对整个果园的每个地方都了如指掌,小易不太相信, 所以他想考考牛牛. 在果园里有N堆苹果,每堆苹果的数 ...
- Druid 架构
本篇译自 Druid 项目白皮书部分内容( https://github.com/apache/incubator-druid/tree/master/publications/whitepaper/ ...
- 带有定位当前位置的百度地图web api 前端代码
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta name="viewport& ...
- 【ASP.NET MVC】HTML5+MVC上传文件显示进度
head> <title>Index</title> <style type="text/css"> #statusBorder { po ...
- 用谷歌浏览器Chrome浏览jQuery Mobile页面需要配置Tomcat服务器
在浏览jQuery Mobile 页面中,除了 Chrome浏览器出错外,其他的浏览器都ok: 这里,是因为需要单独配置 Tomcat 服务: 1.先配置java jdk: 2.下载,安装,配置,To ...
- HDU 1829 A Bug's Life 【带权并查集/补集法/向量法】
Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes ...
- 洛谷——P2141 珠心算测验
P2141 珠心算测验 题目描述 珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术.珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得到普及. 某学校的珠心算老师 ...