Freigeben über


Application.ExistsOnSqlServer(String, String, String, String) Methode

Definition

Gibt einen booleschen Wert zurück, der angibt, ob das angegebene Paket in der Instanz von SQL Server vorhanden ist.

public:
 bool ExistsOnSqlServer(System::String ^ packagePath, System::String ^ serverName, System::String ^ serverUserName, System::String ^ serverPassword);
public bool ExistsOnSqlServer (string packagePath, string serverName, string serverUserName, string serverPassword);
member this.ExistsOnSqlServer : string * string * string * string -> bool
Public Function ExistsOnSqlServer (packagePath As String, serverName As String, serverUserName As String, serverPassword As String) As Boolean

Parameter

packagePath
String

Das Paket, das Sie suchen.

serverName
String

Der Name der SQL Server-Instanz, die nach dem Paket durchsucht werden soll.

serverUserName
String

Der für die SQL Server-Instanz zu authentifizierende Benutzername.

serverPassword
String

Das Kennwort für den angegebenen serverUserName.

Gibt zurück

true, wenn das Paket in der angegebenen Instanz von SQL Server vorhanden ist. false, wenn das Paket nicht vorhanden ist.

Beispiele

Im folgenden Codebeispiel wird ein SQL Server Ordner erstellt, überprüft, ob er vorhanden ist, und entfernt dann den Ordner und überprüft das Vorhandensein erneut. Außerdem wird ein Paket gespeichert und überprüft, ob das Paket mithilfe der ExistsOnSqlServer Methode gespeichert wurde.

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 p = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";  

            Application app = new Application();  

            // Create a folder on SQL Server in the msdb database.  
            app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", null, null);  

            // Verify that the folder exists by using ExistsOnSqlServer method.  
            Boolean folderExists = app.FolderExistsOnSqlServer("myNewFolder", "yourserver", null, null);  
            Console.WriteLine("Folder exists? {0}", folderExists);  

            // Load a package and save it.  
            Package pkg = app.LoadPackage(p, null);  
            app.SaveToSqlServerAs(pkg, null, "newPkg", "yourserver", null, null);  

            // Verify that the package was saved.  
            Boolean packageExists = app.ExistsOnSqlServer("newPkg", "yourserver", null, null);  
            Console.WriteLine("Package exists? {0}", packageExists);  

            //Remove the folder.  
            app.RemoveFolderFromSqlServer("myNewFolder", "yourserver", null, null);  

            // Verify that the folder was removed by using the ExistsOnSqlServer method.  
            folderExists = app.FolderExistsOnSqlServer("myNewFolder", "yourserver", null, null);  
            Console.WriteLine("Folder exists? {0}", folderExists);  
        }  
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 p 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()   

            ' Create a folder on SQL Server in the msdb database.  
            app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", Nothing, Nothing)  

            ' Verify that the folder exists by using ExistsOnSqlServer method.  
            Dim folderExists As Boolean =  app.FolderExistsOnSqlServer("myNewFolder","yourserver",Nothing,Nothing)   
            Console.WriteLine("Folder exists? {0}", folderExists)  

            ' Load a package and save it.  
            Dim pkg As Package =  app.LoadPackage(p,Nothing)   
            app.SaveToSqlServerAs(pkg, Nothing, "newPkg", "yourserver", Nothing, Nothing)  

            ' Verify that the package was saved.  
            Dim packageExists As Boolean =  app.ExistsOnSqlServer("newPkg","yourserver",Nothing,Nothing)   
            Console.WriteLine("Package exists? {0}", packageExists)  

            'Remove the folder.  
            app.RemoveFolderFromSqlServer("myNewFolder", "yourserver", Nothing, Nothing)  

            ' Verify that the folder was removed by using the ExistsOnSqlServer method.  
            folderExists = app.FolderExistsOnSqlServer("myNewFolder", "yourserver", Nothing, Nothing)  
            Console.WriteLine("Folder exists? {0}", folderExists)  
End Sub  

Beispielausgabe:

Folder exists? True

Package exists? True

Folder exists? False

Gilt für: