[转]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的具体调用-->销毁前-- ...
随机推荐
- Eclipse中部署ES源码运行
https://stackoverflow.com/questions/40924671/how-to-build-elasticsearch-source-code-using-gradle Gra ...
- LeetCode Binary Tree PostorderTranversal
Problem Description Given a binary tree, return the postorder traversal of its nodes' values. For ex ...
- AC日记——明明的烦恼 bzoj 1005
1005 思路: prufer编码+组合数: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 #de ...
- lr_Controller界面图
lr可用运行图介绍: lr集合点策略:
- 洛谷 P2947 [USACO09MAR]向右看齐Look Up【单调栈】
题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again stan ...
- Nginx反代,后端一个IP绑定多个SSL证书,导致连接失败之解决方法:HTTPS和SNI扩展
默认:SSL协议进行握手协商进行连接的时候,默认是不会发送主机名的,也就是是以IP的形式来进行https连接握手协商的,这就导致一个问题,当一台服务器上有多个虚拟主机使用同一个IP的时候, Nginx ...
- 分布式框架Dubbo配置和实例
准备工作: 1.ZooKeeper:需要去Apache Zookeeper官网下载Zookeeper.tar.gz包,Dubbo是依赖于Zookeeper的 2.Maven:需要去Apache Mav ...
- Windows下安装Redis服务及安装PHP的Redis扩展
Redis是一个开源的使用ANSI C语言编写.遵守BSD协议.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API. 它通常被称为数据结构服务器,因为值(valu ...
- PMP的六大管理学定律
★墨菲定律PMP考试六大管理学定律之1-PMP专业辅导 1.什么是墨菲定律?最简单的表达形式是“有可能出错的事情,就会出错(Anything that can go wrong will go wro ...
- JZYZOJ1539[haoi2015]T2 树链剖分
http://172.20.6.3/Problem_Show.asp?id=1539 在学校的OJ又写了一次,RE了好多次,原来haoi的时候这道题需要开栈+快读,裸数据结构30分,加上快读50分.o ...