本文转自:http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.connectionmanager.connectionstring.aspx

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)

Syntax

 
 
public string ConnectionString { get; set; }

Property Value

Type: System.String A String that contains the connection string value.

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的更多相关文章

  1. 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 ...

  2. MySQL+Amoeba实现数据库主从复制和读写分离

    MySQL读写分离是在主从复制的基础上进一步通过在master上执行写操作,在slave上执行读操作来实现的.通过主从复制,master上的数据改动能够同步到slave上,从而保持了数据的一致性.实现 ...

  3. OLE DB Command transformation 用法

    OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used ...

  4. 使用http.sys,让delphi 的多层服务飞起来

    核心提示:一直以来,delphi 的网络通讯层都是以indy 为主,虽然indy 的功能非常多,涉及到网络服务的各个方面,但是对于大多数多层服务来说,就是需要一个快速.稳定.高效的传输层.Delphi ...

  5. Amoeba for MySQL读写分离配置

    一.      安装和运行Amoeba 1. Amoeba for MySQL 架构: 2. 验证Java的安装Amoeba框架是基于Java SE1.5开发的,建议使用Java SE1.5以上的版本 ...

  6. Amoeba+Mysql实现数据库读写分离

    一.Amoeba 是什么 Amoeba(变形虫)项目,专注 分布式数据库 proxy 开发.座落与Client.DB Server(s)之间.对客户端透明.具有负载均衡.高可用性.sql过滤.读写分离 ...

  7. C#中使用ADOMD.NET查询多维数据集

    ADOMD.NET 是用于与 Microsoft SQL Server Analysis Services 进行通信的 Microsoft .NET Framework 数据访问接口. ADOMD.N ...

  8. 使用 TFDConnection 的 pooled 连接池

    从开始看到这个属性,就一直认为他可以提供一个连接池管理功能, 苦于文档资料太少, 甚至在帮助中对该属性的使用都没有任何介绍,如果你搜索百度,也会发现基本没资料. 最后终于在其官方网站看到了其完整相关的 ...

  9. (spring-第5回【IoC基础篇】)spring容器从加载配置文件到实例化bean的内部工作机制

    前面讲过,spring的生命周期为:实例化前奏-->实例化-->实例化后期-->初始化前期-->初始化-->初始化后期-->bean的具体调用-->销毁前-- ...

随机推荐

  1. java中的构造方法与其作用

    什么是构造方法呢? 方法名和类名相同 没有返回值类型,连void都不能写 没有具体的返回值 构造方法分为无参构造方法与有参构造方法. 先来看一下最简单的无参构造方法: Student.java pac ...

  2. Django 定制验证码

    一.图片验证码 方式一: def get_validCode_img(request): path=os.path.join(settings.BASE_DIR,'static','image','1 ...

  3. 从零开始,学习web前端之HTML5开发

    什么是HTML5 HTML5是HTML最新的修订版本,2014年10月由万维网联盟(W3C)完成标准制定.是下一代 HTML 标准. 为什么要学习HTML5 HTML5定义了一系列新元素,如新语义标签 ...

  4. HDMI 电视 点对点 桌面超出屏幕

    一直在用电视作显示器,但是没有注意点对点到问题,只是感觉字体发虚.直到今天装win10,桌面会超出屏幕,使用intel控制面板调整分辨率后正常,但是注销或重启会再次回复.百度无果,自己摸索,不仅解决了 ...

  5. bzoj 3295 CDQ求动态逆序对

    #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk mak ...

  6. ASOP编译说明

    具体说明https://source.android.com/source/ 源码下载https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/ 1 搭建编译环境使 ...

  7. 【C++】基础及引用

    输出 #include "iostream" //包含c++的头文件 //iostream.h using namespace std; //使用命名空间 std 标准的命名空间 ...

  8. 洛谷P3901 数列找不同 [莫队]

    题目传送门 题目描述 现有数列 A_1,A_2,\cdots,A_NA1​,A2​,⋯,AN​ ,Q 个询问 (L_i,R_i)(Li​,Ri​) , A_{Li} ,A_{Li+1},\cdots, ...

  9. Flask实战第62天:帖子详情页布局

    在templates/front/下创建详情页面front_pdetail.html 编辑front.views.py创建详情页的视图函数 from flask import abort ... @b ...

  10. Flask实战第56天:板块管理

    cms布局 编辑 cms_boards.html {% block main_content %} <div class="top-box"> <button c ...