Application.FolderExistsOnSqlServer(String, String, String, String) Método

Definição

Retorna um booliano que indica se a pasta especificada já existe na instância do SQL Server.

public:
 bool FolderExistsOnSqlServer(System::String ^ strFolderName, System::String ^ strServerName, System::String ^ strServerUserName, System::String ^ strServerPassword);
public bool FolderExistsOnSqlServer (string strFolderName, string strServerName, string strServerUserName, string strServerPassword);
member this.FolderExistsOnSqlServer : string * string * string * string -> bool
Public Function FolderExistsOnSqlServer (strFolderName As String, strServerName As String, strServerUserName As String, strServerPassword As String) As Boolean

Parâmetros

strFolderName
String

A pasta que você está procurando.

strServerName
String

O nome da instância do SQL Server para pesquisar o pacote.

strServerUserName
String

O nome de usuário para autenticar na instância do SQL Server.

strServerPassword
String

A senha para o strServerUserName determinado.

Retornos

true se a pasta existir na instância especificada de SQL Server; false se a pasta não existir.

Exemplos

O exemplo de código a seguir cria uma pasta no SQL Server, renomeia-a e, em seguida, a remove. Ele também verifica a existência da pasta usando 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  

Saída de exemplo:

myNewFolderExists? True

myNewFolderExists has been renamed but still exists? False

myRenamedFolder now exists? True

myRenamedFolder still exists? False

Aplica-se a