次の方法で共有


ExistsOnDtsServer メソッド

指定したパッケージが Integration Services サービスに既に存在するかどうかを示す Boolean を返します。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public Function ExistsOnDtsServer ( _
    sPackagePath As String, _
    sServerName As String _
) As Boolean
'使用
Dim instance As Application
Dim sPackagePath As String
Dim sServerName As String
Dim returnValue As Boolean

returnValue = instance.ExistsOnDtsServer(sPackagePath, _
    sServerName)
public bool ExistsOnDtsServer(
    string sPackagePath,
    string sServerName
)
public:
bool ExistsOnDtsServer(
    String^ sPackagePath, 
    String^ sServerName
)
member ExistsOnDtsServer : 
        sPackagePath:string * 
        sServerName:string -> bool 
public function ExistsOnDtsServer(
    sPackagePath : String, 
    sServerName : String
) : boolean

パラメーター

戻り値

型: System. . :: . .Boolean
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