Application.ExistsOnSqlServer(String, String, String, String) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 패키지가 SQL Server 인스턴스에 있는지 여부를 나타내는 부울 값을 반환합니다.
public:
bool ExistsOnSqlServer(System::String ^ packagePath, System::String ^ serverName, System::String ^ serverUserName, System::String ^ serverPassword);
public bool ExistsOnSqlServer (string packagePath, string serverName, string serverUserName, string serverPassword);
member this.ExistsOnSqlServer : string * string * string * string -> bool
Public Function ExistsOnSqlServer (packagePath As String, serverName As String, serverUserName As String, serverPassword As String) As Boolean
매개 변수
- packagePath
- String
찾으려는 패키지입니다.
- serverName
- String
패키지를 검색할 SQL Server 인스턴스의 이름입니다.
- serverUserName
- String
SQL Server 인스턴스에 대해 인증할 사용자 이름입니다.
- serverPassword
- String
지정된 serverUserName
의 암호입니다.
반환
지정된 SQL Server 인스턴스에 패키지가 있으면 true입니다. 패키지가 없으면 false입니다.
예제
다음 코드 예제에서는 SQL Server 폴더를 만들고, 폴더가 있는지 확인한 다음, 폴더를 제거하고 해당 폴더의 존재를 다시 확인합니다. 또한 패키지를 저장하고 메서드를 사용하여 ExistsOnSqlServer 패키지가 저장되었는지 확인합니다.
static void Main(string[] args)
{
// The variable pkg points to the location
// of the ExecuteProcess package sample
// that is installed with the SSIS samples.
string p = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";
Application app = new Application();
// Create a folder on SQL Server in the msdb database.
app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", null, null);
// Verify that the folder exists by using ExistsOnSqlServer method.
Boolean folderExists = app.FolderExistsOnSqlServer("myNewFolder", "yourserver", null, null);
Console.WriteLine("Folder exists? {0}", folderExists);
// Load a package and save it.
Package pkg = app.LoadPackage(p, null);
app.SaveToSqlServerAs(pkg, null, "newPkg", "yourserver", null, null);
// Verify that the package was saved.
Boolean packageExists = app.ExistsOnSqlServer("newPkg", "yourserver", null, null);
Console.WriteLine("Package exists? {0}", packageExists);
//Remove the folder.
app.RemoveFolderFromSqlServer("myNewFolder", "yourserver", null, null);
// Verify that the folder was removed by using the ExistsOnSqlServer method.
folderExists = app.FolderExistsOnSqlServer("myNewFolder", "yourserver", null, null);
Console.WriteLine("Folder exists? {0}", folderExists);
}
Sub Main(ByVal args() As String)
' The variable pkg points to the location
' of the ExecuteProcess package sample
' that is installed with the SSIS samples.
Dim p As String = "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"
Dim app As Application = New Application()
' Create a folder on SQL Server in the msdb database.
app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", Nothing, Nothing)
' Verify that the folder exists by using ExistsOnSqlServer method.
Dim folderExists As Boolean = app.FolderExistsOnSqlServer("myNewFolder","yourserver",Nothing,Nothing)
Console.WriteLine("Folder exists? {0}", folderExists)
' Load a package and save it.
Dim pkg As Package = app.LoadPackage(p,Nothing)
app.SaveToSqlServerAs(pkg, Nothing, "newPkg", "yourserver", Nothing, Nothing)
' Verify that the package was saved.
Dim packageExists As Boolean = app.ExistsOnSqlServer("newPkg","yourserver",Nothing,Nothing)
Console.WriteLine("Package exists? {0}", packageExists)
'Remove the folder.
app.RemoveFolderFromSqlServer("myNewFolder", "yourserver", Nothing, Nothing)
' Verify that the folder was removed by using the ExistsOnSqlServer method.
folderExists = app.FolderExistsOnSqlServer("myNewFolder", "yourserver", Nothing, Nothing)
Console.WriteLine("Folder exists? {0}", folderExists)
End Sub
샘플 출력:
Folder exists? True
Package exists? True
Folder exists? False