Application.SaveToSqlServerAs 方法

定义

使用新名称将包保存到 SQL Server 实例。

public:
 void SaveToSqlServerAs(Microsoft::SqlServer::Dts::Runtime::Package ^ package, Microsoft::SqlServer::Dts::Runtime::IDTSEvents ^ events, System::String ^ packagePath, System::String ^ serverName, System::String ^ serverUserName, System::String ^ serverPassword);
public void SaveToSqlServerAs (Microsoft.SqlServer.Dts.Runtime.Package package, Microsoft.SqlServer.Dts.Runtime.IDTSEvents events, string packagePath, string serverName, string serverUserName, string serverPassword);
member this.SaveToSqlServerAs : Microsoft.SqlServer.Dts.Runtime.Package * Microsoft.SqlServer.Dts.Runtime.IDTSEvents * string * string * string * string -> unit
Public Sub SaveToSqlServerAs (package As Package, events As IDTSEvents, packagePath As String, serverName As String, serverUserName As String, serverPassword As String)

参数

package
Package

要保存的包。

events
IDTSEvents

IDTSEvents 对象。

packagePath
String

要分配给包的路径和新名称。 参数 packagePath 的格式为 \folder\packageName。 如果指定 packagePath 时没有现有文件夹,则将使用此参数作为其新名称来保存该包。

serverName
String

SQL Server 实例的名称。

serverUserName
String

用于登录到 SQL Server 实例的帐户的名称。

serverPassword
String

用户帐户的密码。

示例

下面的代码示例使用 myNewPackage 的新名称将名为 ExecuteProcess.dtsx 的示例包保存到 msdb 文件夹。 若要验证包是否已保存,请针对 msdb 数据库运行以下 Transact-SQL 查询。 该查询返回存储在 msdb 系统表中的所有包。

select * from sysssispackages

或者,连接到 Integration Services 服务,展开 存储包,然后展开 MSDB。 将列出具有指定 packagePath 名称的包。

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 to the SQL Server msdb folder, which is  
           // also the MSDB folder in the Integration Services service, or as a row in the  
           //sysssispackages table.  
            app.SaveToSqlServerAs(p, null, "myNewPackage", "yourserver", null, null);  
        }  
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()   
            Dim p As Package =  app.LoadPackage(pkg,Nothing)   

           ' Save the package to the SQL Server msdb folder, which is  
           ' also the MSDB folder in the Integration Services service, or as a row in the  
           'sysssispackages table.  
            app.SaveToSqlServerAs(p, Nothing, "myNewPackage", "yourserver", Nothing, Nothing)  
End Sub  

适用于