次の方法で共有


FolderExistsOnSqlServer メソッド

指定したフォルダーが SQL Server のインスタンスに既に存在するかどうかを示す Boolean を返します。

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

構文

'宣言
Public Function FolderExistsOnSqlServer ( _
    strFolderName As String, _
    strServerName As String, _
    strServerUserName As String, _
    strServerPassword As String _
) As Boolean
'使用
Dim instance As Application
Dim strFolderName As String
Dim strServerName As String
Dim strServerUserName As String
Dim strServerPassword As String
Dim returnValue As Boolean

returnValue = instance.FolderExistsOnSqlServer(strFolderName, _
    strServerName, strServerUserName, _
    strServerPassword)
public bool FolderExistsOnSqlServer(
    string strFolderName,
    string strServerName,
    string strServerUserName,
    string strServerPassword
)
public:
bool FolderExistsOnSqlServer(
    String^ strFolderName, 
    String^ strServerName, 
    String^ strServerUserName, 
    String^ strServerPassword
)
member FolderExistsOnSqlServer : 
        strFolderName:string * 
        strServerName:string * 
        strServerUserName:string * 
        strServerPassword:string -> bool 
public function FolderExistsOnSqlServer(
    strFolderName : String, 
    strServerName : String, 
    strServerUserName : String, 
    strServerPassword : String
) : boolean

パラメーター

  • strServerName
    型: System. . :: . .String
    パッケージを検索する SQL Server のインスタンスの名前です。
  • strServerUserName
    型: System. . :: . .String
    サーバーへのログインに SQL Server 認証を使用している場合は、SQL Server ログイン名です。Windows 認証を使用している場合は、nullNothingnullptrunitNULL 参照 (Visual Basic では Nothing) です。
  • strServerPassword
    型: System. . :: . .String
    サーバーへのログインに SQL Server 認証を使用している場合は、SQL Server ログイン パスワードです。Windows 認証を使用している場合は、nullNothingnullptrunitNULL 参照 (Visual Basic では Nothing) です。

戻り値

型: System. . :: . .Boolean
指定した SQL Server のインスタンスにフォルダーが存在する場合は true です。フォルダーが存在しない場合は false です。

使用例

次のコード例では、SQL Server にフォルダーを作成し、名前を変更してから削除します。また、FolderExistsOnSqlServer を使用して、フォルダーの存在の確認も行います。

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();
            app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", null, null);
            
            // Verify that the folder was created.
            Boolean ssFolder = app.FolderExistsOnSqlServer("\\myNewFolder", "yourserver", null, null);
            Console.WriteLine("myNewFolderExists? " + ssFolder);

            // Rename the myNewFolder to myRenamedFolder. 
            app.RenameFolderOnSqlServer("\\", "myNewFolder", "myRenamedFolder", "yourserver", null, null);

            // Verify that the old folder does not exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myNewFolder", "yourserver", null, null);
            Console.WriteLine("myNewFolderExists has been renamed but still exists? " + ssFolder);

            // Verify that a folder with the new name does exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", null, null);
            Console.WriteLine("myRenamedFolder now exists? " + ssFolder);

            // Delete the folder.
            app.RemoveFolderFromSqlServer("\\myRenamedFolder", "yourserver", null, null);

            // Verify that the folder was removed.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", null, null);
            Console.WriteLine("myRenamedFolder still exists? " + ssFolder);
        }
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() 
            app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", Nothing, Nothing)
 
            ' Verify that the folder was created.
            Dim ssFolder As Boolean =  app.FolderExistsOnSqlServer("\\myNewFolder","yourserver",Nothing,Nothing) 
            Console.WriteLine("myNewFolderExists? " + ssFolder)
 
            ' Rename the myNewFolder to myRenamedFolder. 
            app.RenameFolderOnSqlServer("\\", "myNewFolder", "myRenamedFolder", "yourserver", Nothing, Nothing)
 
            ' Verify that the old folder does not exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myNewFolder", "yourserver", Nothing, Nothing)
            Console.WriteLine("myNewFolderExists has been renamed but still exists? " + ssFolder)
 
            ' Verify that a folder with the new name does exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", Nothing, Nothing)
            Console.WriteLine("myRenamedFolder now exists? " + ssFolder)
 
            ' Delete the folder.
            app.RemoveFolderFromSqlServer("\\myRenamedFolder", "yourserver", Nothing, Nothing)
 
            ' Verify that the folder was removed.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", Nothing, Nothing)
            Console.WriteLine("myRenamedFolder still exists? " + ssFolder)
End Sub

サンプルの出力 :

myNewFolderExists?True

myNewFolderExists has been renamed but still exists?False

myRenamedFolder now exists?True

myRenamedFolder still exists?False