|
Publicité ' | |||||||||||||||||||||||
|
|
#1 |
|
Invité régulier
![]() Inscription : janvier 2007 Messages : 13 ![]() |
Bonjour,
J ecris sur ce forum car je ne m en sors plus! je voudrai lancer un abonnement "deja cree", il est donc present sur le serveur "BDD-TEST" , je verifie que la publication s y trouve egalement (pour les test ils se trouvent sur le meme serveur"), a l execution, le programme detecte bien la presence des deux fichiers sur le serveur, et rempli correctement mes objets "publication" et "subscription"( serveur, base de donnee, nom des scripts) ...cependant lorsque j arrive sur : "subscription.SynchronizeWithJob(); " il explose en me disant que : "L'abonnement est introuvable. Le contexte de la base de données a changé*; il est maintenant 'Test_Publication'." Or si l abonnement etait introuvable pouquoi l a t il detecte auparavant? si quelqu un pouvait me dire si j utilise correctement ces objets car a part msdn , je n ai pas vraiment d autres exemples! MergePublication publication; MergeSubscription subscription; try { // Connect to the Publisher. conn.Connect(); // Ensure that the publication exists and that // it supports push subscriptions. publication = new MergePublication(); publication.Name = "Test_Publication"; publication.DatabaseName = "Test_Publication"; publication.ConnectionContext = conn; if (publication.IsExistingObject) { if ((publication.Attributes & PublicationAttributes.AllowPush) == 0) { publication.Attributes |= PublicationAttributes.AllowPush; } // Define the push subscription. subscription = new MergeSubscription(); subscription.ConnectionContext = conn; subscription.SubscriberName = "TEST-BDD"; subscription.PublicationName = "Test_Publication"; subscription.DatabaseName = "Test_Publication"; subscription.SubscriptionDBName = "Test_Abonnement"; if (!conn.IsOpen) conn.Connect(); if (subscription.IsExistingObject == false) subscription.Create(); subscription.Refresh(); subscription.Load(); if (subscription.AgentJobId != null) { // Start the Merge Agent asynchronously. subscription.SynchronizeWithJob(); } } else { // Do something here if the publication does not exist. throw new ApplicationException(String.Format( "The publication '{0}' does not exist on {1}.", "", "")); } } catch (Exception ex) { // Implement the appropriate error handling here. throw new ApplicationException(String.Format( "The subscription to {0} could not be created.", ""), ex); } finally { conn.Disconnect(); } |
|
|
00
|
|
|
#2 |
|
Invité régulier
![]() Inscription : janvier 2007 Messages : 13 ![]() |
j ai trouve!
en fait il faut utiliser une autre classe car il existe deux type d abonnement! pull et push...ainsi pour les type pull il faut utiliser un "MergePullSubscription" a la place de "MergeSubscription" le reste du code ne change pas...(ou presque Merci bien |
|
|
00
|
Copyright © 2000-2012 - www.developpez.com