Compartir a través de


Application.RenameFolderOnSqlServer Método

Definición

Cambia el nombre de una carpeta en la instancia especificada de SQL Server.

public:
 void RenameFolderOnSqlServer(System::String ^ strParent, System::String ^ strOldName, System::String ^ strNewName, System::String ^ strServerName, System::String ^ strServerUserName, System::String ^ strServerPassword);
public void RenameFolderOnSqlServer (string strParent, string strOldName, string strNewName, string strServerName, string strServerUserName, string strServerPassword);
member this.RenameFolderOnSqlServer : string * string * string * string * string * string -> unit
Public Sub RenameFolderOnSqlServer (strParent As String, strOldName As String, strNewName As String, strServerName As String, strServerUserName As String, strServerPassword As String)

Parámetros

strParent
String

Nombre de la carpeta principal.

strOldName
String

Nombre de la carpeta existente.

strNewName
String

Nombre nuevo de la carpeta.

strServerName
String

Nombre de la instancia de SQL Server.

strServerUserName
String

El nombre de usuario que se va a usar al autenticarse en el servidor.

strServerPassword
String

La contraseña asociada a la cuenta strServerUserName.

Ejemplos

En el ejemplo de código siguiente se crea una carpeta en SQL Server, se le cambia el nombre y, a continuación, se quita.

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 new 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);  
        }  
Shared  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 new 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  

Salida del ejemplo:

myNewFolderExists? True

myNewFolderExists has been renamed but still exists? False

myRenamedFolder now exists? True

myRenamedFolder still exists? False

Se aplica a