[转]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的具体调用-->销毁前-- ...
随机推荐
- linux命令(7):ipcs/ipcrm命令
ipcs作用 :查看消息队列(ipcs –q).共享内存(ipcs –m).信号灯(ipcs -s) ipcrm作用 :删除消息队列.共享内存.信号灯 ipcrm使用方式: ipcrm [ -M ke ...
- 多路复用I/O模型poll() 模型 代码实现
多路复用I/O模型poll() 模型 代码实现 poll()机制和select()机制是相似的,都是对多个描述符进行轮询的方式. 不同的是poll()没有描述符数目的限制. 是通过struct pol ...
- 《java并发编程实战》读书笔记10--显示锁Lock,轮询、定时、读写锁
第13章 显示锁 终于看到了这本书的最后一本分,呼呼呼,真不容易.其实说实在的,我不喜欢半途而废,有其开始,就一定要有结束,否则的话就感觉哪里乖乖的. java5.0之前,在协调对共享对象的访问时可以 ...
- 【DUBBO】dubbo的Router接口
Router服务路由, 根据路由规则从多个Invoker中选出一个子集AbstractDirectory是所有目录服务实现的上层抽象, 它在list列举出所有invokers后,会在通过Router服 ...
- [转]windows消息机制(MFC)
消息分类与消息队列 Windows中,消息使用统一的结构体(MSG)来存放信息,其中message表明消息的具体的类型, 而wParam,lParam是其最灵活的两个变量,为不同的消息类型时,存放数据 ...
- IllegalStateException: Unable to find a @SpringBootConfiguration
此处需要改掉包名和类名
- ubuntu16.04编译安装GPAC
参考:http://blog.csdn.net/tianlong_hust/article/details/9273875 1.获取gpac的源代码 sudo apt-get install subv ...
- 编译python可以调用的dll
如果经过stdcall声明的方法,如果不是用def文件声明的导出函数或者extern “C” 声明的话,编译器会对函数名进行修改;在编译加上extern C:这样就OK了:另外可以在PYTHON代码里 ...
- thinkphp之url的seo优化
1.网站url做seo优化的原因 SEO是由英文Search Engine Optimization缩写而来, 中文意译为“搜索引擎优化”.SEO是指通过对网站进行站内优化(网站结构调整.网站内容建设 ...
- MYSQL注入天书之基础知识
第一部分/page-1 Basic Challenges Background-1 基础知识 此处介绍一些mysql注入的一些基础知识. (1)注入的分类---仁者见仁,智者见智. 下面这个是阿德玛表 ...