Application.ExistsOnDtsServer(String, String) 方法

定义

返回一个布尔值,该值指示 Integration Services 服务上是否已存在指定的包。

public:
 bool ExistsOnDtsServer(System::String ^ sPackagePath, System::String ^ sServerName);
public bool ExistsOnDtsServer (string sPackagePath, string sServerName);
member this.ExistsOnDtsServer : string * string -> bool
Public Function ExistsOnDtsServer (sPackagePath As String, sServerName As String) As Boolean

参数

sPackagePath
String

包的完全限定路径。

sServerName
String

要搜索该包的服务器的名称。

返回

如果命名sServerName的服务器上存在指定的sPackagePath包,则为 true;否则为 false。

示例

下面的代码示例演示了将包保存到父文件夹 myFolder2下的文件系统。 然后,该示例通过查询方法 ExistsOnDtsServer 来检查包是否已保存。

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 pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";  

            Application app = new Application();  
            Package p = app.LoadPackage(pkg, null);  

            // Save the package under myFolder which is found under the   
            // File System folder on the DTS Service  
            app.SaveToDtsServer(p, null, @"File System\myFolder2", "yourserver");  

            // Verify that the package was saved by   
            // using ExistsOnDtsServer.  
            Boolean packageExists = app.ExistsOnDtsServer(@"File System\myFolder", "yourserver");  
            Console.WriteLine("Package exists? " + packageExists);  
        }  
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 pkg 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()   
            Dim p As Package =  app.LoadPackage(pkg,Nothing)   

            ' Save the package under myFolder which is found under the   
            ' File System folder on the DTS Service  
            app.SaveToDtsServer(p, Nothing, "File System\myFolder2", "yourserver")  

            ' Verify that the package was saved by   
            ' using ExistsOnDtsServer.  
            Dim packageExists As Boolean =  app.ExistsOnDtsServer("File System\myFolder", "yourserver")   
            Console.WriteLine("Package exists? " + packageExists)  
End Sub  

示例输出:

Folder exists? True

Package exists? True

Folder exists? False

适用于