Application.ExistsOnSqlServer Yöntemi
Döndürür bir Boole üzerinde belirtilen paket var olup olmadığını belirten örnek , SQL Server.
Ad Alanı: Microsoft.SqlServer.Dts.Runtime
Derleme: Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS içinde.dll)
Sözdizimi
'Bildirim
Public Function ExistsOnSqlServer ( _
packagePath As String, _
serverName As String, _
serverUserName As String, _
serverPassword As String _
) As Boolean
'Kullanım
Dim instance As Application
Dim packagePath As String
Dim serverName As String
Dim serverUserName As String
Dim serverPassword As String
Dim returnValue As Boolean
returnValue = instance.ExistsOnSqlServer(packagePath, _
serverName, serverUserName, serverPassword)
public bool ExistsOnSqlServer(
string packagePath,
string serverName,
string serverUserName,
string serverPassword
)
public:
bool ExistsOnSqlServer(
String^ packagePath,
String^ serverName,
String^ serverUserName,
String^ serverPassword
)
member ExistsOnSqlServer :
packagePath:string *
serverName:string *
serverUserName:string *
serverPassword:string -> bool
public function ExistsOnSqlServer(
packagePath : String,
serverName : String,
serverUserName : String,
serverPassword : String
) : boolean
Parametreler
- packagePath
Tür: System.String
Aradığınız paket.
- serverName
Tür: System.String
Adı örnek , SQL Server Arama paket.
- serverUserName
Tür: System.String
SQL Server Oturum açma adı kullanırsanız SQL Server ; sunucuya oturum açmak için kimlik doğrulama Aksi takdirde, nullnull başvuru (Visual Basic'te Nothing) , Windows kimlik doğrulaması kullanıyorsanız.
- serverPassword
Tür: System.String
SQL Server Oturum açma parolası kullanırsanız SQL Server ; sunucuda oturum kimlik doğrulaması Aksi takdirde, nullnull başvuru (Visual Basic'te Nothing) , Windows kimlik doğrulaması kullanıyorsanız.
Dönüş Değeri
Tür: System.Boolean
doğru paket üzerinde belirtilen örnek varsa, SQL Server. yanlış paket yoksa.
Örnekler
Aşağıdaki kod örneği oluşturur bir SQL Server klasörü, doğrular olduğunu var ve ardından klasör kaldırır ve güvenli bir şekilde okunabilmesini onun varlığı.Ayrıca, paket kaydeder ve paket kullanılarak kaydedilmiş olan doğrular ExistsOnSqlServer yöntem.
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
Örnek Çıktı:
Folder exists? True
Package exists? True
Folder exists? False