Metoda TransPublication.RemovePullSubscription
Usuwa rejestracji dla subskrypcja wciągana przez wydawcę.
Przestrzeń nazw: Microsoft.SqlServer.Replication
Zestaw: Microsoft.SqlServer.Rmo (w Microsoft.SqlServer.Rmo.dll)
Składnia
'Deklaracja
Public Sub RemovePullSubscription ( _
subscriber As String, _
subscriptionDB As String _
)
'Użycie
Dim instance As TransPublication
Dim subscriber As String
Dim subscriptionDB As String
instance.RemovePullSubscription(subscriber, _
subscriptionDB)
public void RemovePullSubscription(
string subscriber,
string subscriptionDB
)
public:
void RemovePullSubscription(
String^ subscriber,
String^ subscriptionDB
)
member RemovePullSubscription :
subscriber:string *
subscriptionDB:string -> unit
public function RemovePullSubscription(
subscriber : String,
subscriptionDB : String
)
Parametry
- subscriber
Typ: System.String
A String wartość, która reprezentuje nazwę subskrybenta, gdzie subskrypcja wciągana istnieje.
- subscriptionDB
Typ: System.String
A String wartość, która reprezentuje baza danych subskrypcja nazwy.
Uwagi
RemovePullSubscription Metoda może być wywoływana tylko przez członków sysadmin roli serwera stałych Wydawca, przez członków db_owner ustaloną rola bazy danych na baza danych publikacja, lub przez użytkownika, który utworzył subskrypcja usuwana.
Wywołanie RemovePullSubscription jest równoważne wykonywanie sp_dropsubscription.
Ten obszar nazw, klasy lub element członkowski jest obsługiwany tylko w wersja 2.0.NET Framework.
Przykłady
// Define the Publisher, publication, and databases.
string publicationName = "AdvWorksProductTran";
string publisherName = publisherInstance;
string subscriberName = subscriberInstance;
string subscriptionDbName = "AdventureWorks2008R2Replica";
string publicationDbName = "AdventureWorks2008R2";
//Create connections to the Publisher and Subscriber.
ServerConnection subscriberConn = new ServerConnection(subscriberName);
ServerConnection publisherConn = new ServerConnection(publisherName);
// Create the objects that we need.
TransPublication publication;
TransPullSubscription subscription;
try
{
// Connect to the Subscriber.
subscriberConn.Connect();
// Define the pull subscription.
subscription = new TransPullSubscription();
subscription.ConnectionContext = subscriberConn;
subscription.PublisherName = publisherName;
subscription.PublicationName = publicationName;
subscription.PublicationDBName = publicationDbName;
subscription.DatabaseName = subscriptionDbName;
// Define the publication.
publication = new TransPublication();
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
publication.ConnectionContext = publisherConn;
// Delete the pull subscription, if it exists.
if (subscription.IsExistingObject)
{
if (publication.LoadProperties())
{
// Remove the pull subscription registration at the Publisher.
publication.RemovePullSubscription(subscriberName, subscriptionDbName);
}
else
{
// Do something here if the publication does not exist.
throw new ApplicationException(String.Format(
"The publication '{0}' does not exist on {1}.",
publicationName, publisherName));
}
// Delete the pull subscription at the Subscriber.
subscription.Remove();
}
else
{
throw new ApplicationException(String.Format(
"The subscription to {0} does not exist on {1}",
publicationName, subscriberName));
}
}
catch (Exception ex)
{
// Implement the appropriate error handling here.
throw new ApplicationException(String.Format(
"The subscription to {0} could not be deleted.", publicationName), ex);
}
finally
{
subscriberConn.Disconnect();
publisherConn.Disconnect();
}
' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksProductTran"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2008R2Replica"
Dim publicationDbName As String = "AdventureWorks2008R2"
'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)
' Create the objects that we need.
Dim publication As TransPublication
Dim subscription As TransPullSubscription
Try
' Connect to the Subscriber.
subscriberConn.Connect()
' Define the pull subscription.
subscription = New TransPullSubscription()
subscription.ConnectionContext = subscriberConn
subscription.PublisherName = publisherName
subscription.PublicationName = publicationName
subscription.PublicationDBName = publicationDbName
subscription.DatabaseName = subscriptionDbName
' Define the publication.
publication = New TransPublication()
publication.Name = publicationName
publication.DatabaseName = publicationDbName
publication.ConnectionContext = publisherConn
' Delete the pull subscription, if it exists.
If subscription.IsExistingObject Then
If publication.LoadProperties() Then
' Remove the pull subscription registration at the Publisher.
publication.RemovePullSubscription(subscriberName, subscriptionDbName)
Else
' Do something here if the publication does not exist.
Throw New ApplicationException(String.Format( _
"The publication '{0}' does not exist on {1}.", _
publicationName, publisherName))
End If
' Delete the pull subscription at the Subscriber.
subscription.Remove()
Else
Throw New ApplicationException(String.Format( _
"The subscription to {0} does not exist on {1}", _
publicationName, subscriberName))
End If
Catch ex As Exception
' Implement the appropriate error handling here.
Throw New ApplicationException(String.Format( _
"The subscription to {0} could not be deleted.", publicationName), ex)
Finally
subscriberConn.Disconnect()
publisherConn.Disconnect()
End Try