Metoda Application.SaveToSqlServerAs
Zapisuje pakiet do wystąpienie SQL Server z nowej nazwy.
Przestrzeń nazw: Microsoft.SqlServer.Dts.Runtime
Zestaw: Microsoft.SqlServer.ManagedDTS (w Microsoft.SqlServer.ManagedDTS.dll)
Składnia
'Deklaracja
Public Sub SaveToSqlServerAs ( _
package As Package, _
events As IDTSEvents, _
packagePath As String, _
serverName As String, _
serverUserName As String, _
serverPassword As String _
)
'Użycie
Dim instance As Application
Dim package As Package
Dim events As IDTSEvents
Dim packagePath As String
Dim serverName As String
Dim serverUserName As String
Dim serverPassword As String
instance.SaveToSqlServerAs(package, events, _
packagePath, serverName, serverUserName, _
serverPassword)
public void SaveToSqlServerAs(
Package package,
IDTSEvents events,
string packagePath,
string serverName,
string serverUserName,
string serverPassword
)
public:
void SaveToSqlServerAs(
Package^ package,
IDTSEvents^ events,
String^ packagePath,
String^ serverName,
String^ serverUserName,
String^ serverPassword
)
member SaveToSqlServerAs :
package:Package *
events:IDTSEvents *
packagePath:string *
serverName:string *
serverUserName:string *
serverPassword:string -> unit
public function SaveToSqlServerAs(
package : Package,
events : IDTSEvents,
packagePath : String,
serverName : String,
serverUserName : String,
serverPassword : String
)
Parametry
- package
Typ: Microsoft.SqlServer.Dts.Runtime.Package
Pakiet, aby zapisać.
- events
Typ: Microsoft.SqlServer.Dts.Runtime.IDTSEvents
IDTSEvents Obiektu.
- packagePath
Typ: System.String
ścieżka i nazwę nowego przypisać do pakiet.Parametr packagePath jest w formacie \\folder\\packageName.Jeśli packagePath jest określona bez istniejącego folderu, pakiet zostanie zapisany za pomocą tego parametru, jako jej nową nazwę.
- serverName
Typ: System.String
Nazwa wystąpienie SQL Server.
- serverUserName
Typ: System.String
SQL Server Nazwę logowania, jeśli używasz SQL Server uwierzytelniania, aby zalogować się do serwera; w przeciwnym razie nullodwołanie o wartości null (Nothing w języku Visual Basic) korzystania z uwierzytelniania systemu Windows.
- serverPassword
Typ: System.String
SQL Server Hasło logowania, jeśli używasz SQL Server uwierzytelniania, aby zalogować się do serwera; w przeciwnym razie nullodwołanie o wartości null (Nothing w języku Visual Basic) korzystania z uwierzytelniania systemu Windows.
Przykłady
Poniższy przykład kodu zapisuje pakiet próbki o nazwie ExecuteProcess.dtsx do msdb folder z nową nazwę myNewPackage.Aby sprawdzić, czy pakiet został zapisany, uruchom następującą kwerendę języka Transact-SQL przeciwko msdb bazy danych.Kwerenda zwraca wszystkie pakiety przechowywane w msdb tabela systemowa.
select * from sysssispackages
Lub połącz się z Integration Services usługa, rozwiń węzeł Przechowywane pakiety, a następnie rozwiń MSDB.Pakiet z nazwą określoną w packagePath zostaną wyświetlone.
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