Wednesday, March 21, 2012

Merge replication problem

Hi!

I have problem with merge replication between SQL Server Mobile 2005 and SQL Server 2000 SP4. In 99% situation replication is done succesfully, but sometimes some of the rows are not moved from pocket pc to my server. In this situation column __sysSR is NULL. Please help!!! I use managed code and BeginSynchronize method to start replication!

I use this code:

Private Sub repliciraj_gprs()
Try
Me.LabelStatusValue.ForeColor = Color.DarkBlue
Me.MenuItem1.Enabled = False
Me.MenuItem2.Enabled = False
'Me.ButtonSynchronize.Enabled = False
'Me.Button2.Enabled = False
'Dim connected As Boolean = False

Me.repl = New SqlCeReplication()
repl.SubscriberConnectionString = "Data Source=dokumenti.sdf"

If File.Exists("/dokumenti.sdf") = False Then

Dim Gprs As String = Registry.GetValue("HKEY_LOCAL_MACHINE\Putnik\", "Gprs", "")
Dim Publisher As String = Registry.GetValue("HKEY_LOCAL_MACHINE\Putnik\", "Publisher", "")
Dim Baza As String = Registry.GetValue("HKEY_LOCAL_MACHINE\Putnik\", "Baza", "")
Dim User As String = Registry.GetValue("HKEY_LOCAL_MACHINE\Putnik\", "User", "")
Dim Password As String = Registry.GetValue("HKEY_LOCAL_MACHINE\Putnik\", "Password", "")
Dim Publication As String = Registry.GetValue("HKEY_LOCAL_MACHINE\Putnik\", "Publication", "")

repl.AddSubscription(AddOption.CreateDatabase)
repl.InternetUrl = Gprs & "/replikator/sqlcesa30.dll"
repl.Publisher = Publisher
repl.PublisherDatabase = Baza
repl.PublisherLogin = User
repl.PublisherPassword = Password
repl.Publication = Publication
repl.Subscriber = "MySubscriber"

MessageBox.Show("Nakon zavr?etka replikacije bit ?e kreirana nova baza za putnika", "Upozorenje")
Else
repl.LoadProperties()
End If

Label1.Text = "DNS: " & repl.InternetUrl & ", Izdava?: " & repl.Publisher & ", Publikacija: " & repl.Publication & ", Pretplatnik: " & repl.Subscriber

konekcija.Connect(True, ConnectionMode.Synchronous) 'Sinkrono da sa?eka kraj spajanja

Dim ar As IAsyncResult = repl.BeginSynchronize( _
New AsyncCallback(AddressOf Me.SyncCompletedCallback), _
New OnStartTableUpload(AddressOf Me.OnStartTableUploadCallback), _
New OnStartTableDownload(AddressOf Me.OnStartTableDownloadCallback), _
New OnSynchronization(AddressOf Me.OnSynchronizationCallback), repl)

Catch ex As SqlCeException
MessageBox.Show("Pojavila se gre?ka: " & ex.Message & ", provjerite konekciju", "Gre?ka pri repliciranju")
Catch x As Exception
MessageBox.Show(x.Message, "Gre?ka pri repliciranju")
End Try

End Sub

Please, anyone? Help!|||

Hi Ivica,

The post at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=508786&SiteID=1 provides information about the system columns. Have you notices a particular condition when the data is not uploaded from SQL Mobile to SQL Server. The condition can be column trpe, any particular insert etc. This will help in troubleshooting the issue

Regards,

Ambrish

|||Ok that, but did somebody solved this problem already?|||same thing happens to me. build no. of my sql server 2005 is 9.0.3175

|||

I am experiencing what appears to be the same issue:

SQL CE 3.0 using merge replication against a SQL 2000 SP4 back-end.

Appears to work in 99% of cases but in some cases does not work - non-convergence.

Our mobile application performs merge replication every 5 minutes. On the deice this behaviour has been observed, the device is continuing to synchronise successfully - but the row changes that have been found to have failed never update on the server - despite being present in the mobile database table.

For each of the rows that failed, the __sysMC column has a value of 0x81 and __sysSR is null. All the rows fall into one of two values for the __sysCG column (change generation). Some of the other rows in the same table with the same change generation value DID replicate correctly however.

I have a copy of the .SDF file from the device for diagnosis if required.

The mobile device connects to the back-end server over a remote wireless network which is obviously unreliable by nature. It is entirely possible that communications could be disrupted during a synchronisation. It was my understanding that replication could handle this scenario gracefully.

The only other point worth noting is that the date on the device is set incorrectly, and so the __sysCD column has a value set back in 2005. Without knowing how merge replication works under the hood I am unsure whether this should make any difference.

I am very keen to have this issue diagnosed and am happy to provide any information necessary.

|||

It is important that the device date is properly set. My experience is that sync between SQL Mobile 3.0 and SQL Server 2000 is not very reliable, as the backend technology has not been updated since SQL Server 2000 was released. Many improvements have been made to merge sync in SQL Server 2005 (must be SP2 or later)

|||

What effect does having the wrong date have?

If the date was critical to the replication algorithm then I would expect it to fail entirely - yet what I am seeing is that a small number of rows appear not to have replicated.

Is this a known issue that is resolved in SQL Server 2005?

|||If you are filtering based on dates, you may see issues. For a workaround see http://msdn2.microsoft.com/en-us/library/ms365153.aspx|||

We aren't using any row filters based on dates - we only use static row filters that don't involve any date types.

|||

Ivica

We have a very similar issue to the one you have raised here. Our solution uses the same system components as yours and (on very rare occassions) we see that updates made to a particualr column on a particualar mobile database table are not reflected in the master database following a successful synchronisation through SQL Server Merge Replication.

Did you have any success on getting an answer to your query? If so, I would be very grateful if you could post this information on here.

Regards
David.

No comments:

Post a Comment