ConnectionManager.ConnectionString 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 소스와의 연결을 설정하는 데 사용되는 연결 문자열을 얻거나 설정합니다.
public:
property System::String ^ ConnectionString { System::String ^ get(); void set(System::String ^ value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "ConnectionStringDesc")]
[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)]
public string ConnectionString { get; set; }
[<Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "ConnectionStringDesc")>]
[<System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)>]
member this.ConnectionString : string with get, set
Public Property ConnectionString As String
속성 값
연결 문자열 값을 포함하는 문자열입니다.
- 특성
예제
다음 코드 예시는 패키지에서 a FileSystemTask as an Executable 를 생성합니다.
FileSystemTask 테스트 폴더 하나에 두 개의 하위 폴더와 .txt 파일이 들어 있는 폴더를 다른 폴더로 복사합니다. 소스와 목적지는 기존 폴더입니다. 따라서 와 는 IsDestinationPathVariable 로 설정false되고, and Source 속성은 Destination 생성된 두 개의 FILE 연결 관리자를 참조하도록 설정되어 있으며, 이 연결 문자열은 경로를 포함하는 참조 Strings 로 설정되어 IsSourcePathVariable 있습니다.
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();
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask
Namespace FileSystemTask_API
Class Program
Shared Sub Main(ByVal args() As String)
Dim sourceDir As String = "C:\TestFolder"
Dim destDir As String = "C:\MyNewTestFolder"
Dim pkg As Package = New Package()
Dim exec1 As Executable = pkg.Executables.Add("STOCK:FileSystemTask")
Dim th As TaskHost = 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.
Dim cm As ConnectionManager = 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.
Dim cmdest As ConnectionManager = 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.
Dim result As DTSExecResult = pkg.Execute()
End Sub
End Class
End Namespace
설명
연결 문자열의 형식과 내용은 데이터 제공자, 데이터 소스, 그리고 생성되는 연결 관리자 유형에 따라 달라집니다. 샘플 연결 문자열을 보려면 SQL Server Data Tools에서 패키지를 생성한 후, 해당 패키지 내에서 적절한 유형의 연결 관리자를 생성합니다. 다음, 속성 창에서 방금 만든 연결 관리자의 속성을 살펴보 ConnectionString 세요.
다음 코드 예시는 OLE DB 연결 관리자를 추가하고, 연결 관리자 이름과 연결 문자열 속성을 설정합니다.
// 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;";
' Add the OLE DB connection manager.
Dim adventureWorks As ConnectionManager = 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;"
XML 연결 문자열의 경우, 연결 문자열 값은 다음과 유사한 형식으로 작성됩니다:
String myConnString = @"C:\Program Files\Microsoft SQL Server\orders.xml";
반면 OLE DB 연결의 경우, 연결 문자열은 다음과 같은 연결 문자열과 유사한 값을 포함합니다:
String myConnString = "Server=MYSERVER;Provider=SQLOLEDB.1;Pwd= xxxxxxx;User ID= xxxxx;Initial Catalog=mySource;OLE DB Services=-2";
ODBC 연결 문자열은 다음과 같은 형태일 수 있습니다:
String myConnString = "DSN=LocalServer;DATABASE=MySource;PWD=xxxxxxx;UID=xxxxx";
SSIS 디자이너의 연결 속성 대화상자에서 이 값은 연결 문자열 속성으로 나타납니다.
제품에 포함된 모든 연결 관리자 목록은 통합 서비스(SSIS) 연결을 참조하세요.