다음을 통해 공유


Application.ExistsOnSqlServer Method

Returns a Boolean that indicates whether the specified package exists on the instance of SQL Server.

네임스페이스: Microsoft.SqlServer.Dts.Runtime
어셈블리: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

구문

‘선언
Public Function ExistsOnSqlServer ( _
    packagePath As String, _
    serverName As String, _
    serverUserName As String, _
    serverPassword As String _
) As Boolean
public bool ExistsOnSqlServer (
    string packagePath,
    string serverName,
    string serverUserName,
    string serverPassword
)
public:
bool ExistsOnSqlServer (
    String^ packagePath, 
    String^ serverName, 
    String^ serverUserName, 
    String^ serverPassword
)
public boolean ExistsOnSqlServer (
    String packagePath, 
    String serverName, 
    String serverUserName, 
    String serverPassword
)
public function ExistsOnSqlServer (
    packagePath : String, 
    serverName : String, 
    serverUserName : String, 
    serverPassword : String
) : boolean

매개 변수

  • packagePath
    The package you are looking for.
  • serverName
    The name of the instance of SQL Server to search for the package.
  • serverUserName
    The user name to authenticate against the instance of SQL Server.
  • serverPassword
    The password for the specified serverUserName.

반환 값

true if the package exists on the specified instance of SQL Server. false if the package does not exist.

The following code example creates a SQL Server folder, verifies that it exists, and then removes the folder and rechecks its existence. It also saves a package and verifies that the package was saved using the ExistsOnSqlServer method.

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\90\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\90\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

Sample Output:

Folder exists? True

Package exists? True

Folder exists? False

스레드 보안

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

플랫폼

개발 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

대상 플랫폼

지원되는 플랫폼 목록은 SQL Server 2005 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.

참고 항목

참조

Application Class
Application Members
Microsoft.SqlServer.Dts.Runtime Namespace