Application.RenameFolderOnSqlServer 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在 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)
参数
- strParent
- String
父文件夹的名称。
- strOldName
- String
现有文件夹的名称。
- strNewName
- String
文件夹的新名称。
- strServerName
- String
SQL Server 实例的名称。
- strServerUserName
- String
对服务器进行身份验证时要使用的用户名。
- strServerPassword
- String
与 strServerUserName
帐户关联的密码。
示例
下面的代码示例在SQL Server上创建一个文件夹,将其重命名,然后将其删除。
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
示例输出:
myNewFolderExists? True
myNewFolderExists has been renamed but still exists? False
myRenamedFolder now exists? True
myRenamedFolder still exists? False