Re: Application is closed during second synchronization

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Your schema versions do not match. If you reinitialize, it will clean this
up.

--
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com


"Lonifasiko" <mloichate@xxxxxxxxx> wrote in message
news:1136285094.858729.123150@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've been able to start the Merge Agent from SQL Server 2005 Management
Studio. Agent runs correctly.

Some clarifications:
I use always Merge Replication.
My application initially checks if there is a local database
(downloaded before maybe); if there is, the synchronization is
asynchronous because we have data to play with.
If there is no database, I make a synchronous call with Synchronize()
method and wait. Then, I again have got data to play with. Next calls
will also be asynchronous.
This is the merge replication code I'm using. Really simple:

private void CheckReplicationStatus(object sender, EventArgs e)
{
if (true)
{
try
{
ConfigureReplicationManager();
if (replicationManager != null &&
systemCanReplicate)
{

replicationManager.HostName = userId;

// Check if the database file already exists
if
(!System.IO.File.Exists(Constants.DatabaseFilePath))
{
// Add a new subscripton and create the
local database file

replicationManager.AddSubscription(AddOption.CreateDatabase);

// La replicación inicial es
necesariamente síncrona ya que no existe la BD en local
replicationManager.Synchronize();

replicationManager.Dispose();

}
else
{
// Replicación asíncrona
IAsyncResult ar =
replicationManager.BeginSynchronize(new
AsyncCallback(SyncCompletedCallback), replicationManager);
}
}
else // No ha sido capaz de leer los ficheros de
configuración y no ha podido configurar la replicación
{
// La idea es ver si la BD existe en el
dispositivo --> Se le deja continuar ejecutando la aplicación
// pero se cancela la replicación. Pero no hay
manera ya que el path de la BD está también en los ficheros de
configuración

GeneralBehaviour.ShowErrorMessage(Properties.Resources.MasterForm_CannotReadConfigurationFiles);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToUpper());
replicationManager.Dispose();



GeneralBehaviour.ShowErrorMessage(Properties.Resources.MasterForm_InitialSynchronizationFailed);
// TODO: BORRAR LA BD YA QUE NO ES UNA BD OPERATIVA
Application.Exit();
}
}
}

/// <summary>
/// Evento que recoge los resultados de la sincronización
asíncrona
/// </summary>
/// <param name="ar"></param>
public void SyncCompletedCallback(IAsyncResult ar)
{
try
{
SqlCeReplication repl =
(SqlCeReplication)ar.AsyncState;

replicationManager = (SqlCeReplication)ar.AsyncState;

replicationManager.EndSynchronize(ar);
}
catch (SqlCeException exc)
{
// Fallo en la sincronización asíncrona --> La
aplicación sigue corriendo ya que tenemos BD en local
replicationManager.CancelSynchronize();
}
finally
{
replicationManager.Dispose();
}
}

This is all what I have Paul. Don't know what to do yet! It was working
and I'm spending my second day after a solution for this.
What do you think? Seems SQL Server's fault to me but cannot explain
why only fails second synchronization after first synchronization in
which I download all database.

Thanks for your time. Regards.


.



Relevant Pages

  • Re: Application is closed during second synchronization
    ... I've been able to start the Merge Agent from SQL Server 2005 Management ... My application initially checks if there is a local database ... if there is, the synchronization is ... This is the merge replication code I'm using. ...
    (microsoft.public.sqlserver.replication)
  • Do this plan sound feasible?
    ... and Banda Aceh - it's for an NGO working with the Tsunami relief). ... connection is too slow to run the DB over. ... I am facing a problem which I think is best solved by replication. ... could I do direct synchronization? ...
    (microsoft.public.access.replication)
  • Re: Replica Synchronisation and so on.
    ... down the replication road unless it is absolutely required. ... would require some synchronization, though not a whole lot since they ... Utter Access VIP ... into a Design Master. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Is replication the right answer for this scenario
    ... The reference to Excel data has only to do with the fact that they are ... The replication comes into play because the principals of the business want ... >> and synchronization will only take place while connected to their LAN. ... > The best way to minimize conflicts is to keep them from happening in the ...
    (microsoft.public.access.replication)
  • Re: Replication Manager
    ... folder called 'Synchronization', ... As I reviewed the Replication White Paper, ... * Graphical user interface and tools for system ... without needing ReplMan, ...
    (microsoft.public.access.replication)