Hi,
I am writing an application for a device (HP IPAQ 6828) having Windows Mobile 5.0 using
-MS .NET Compact Framework 2.0 SP-1
-SQL Mobile 2005.
-VS 2005 .NET
The application uses Merge Replication. The error occurs in the Synchronise() Method of the SqlCeReplication object.
"SQL Server Mobile encountered problems when opening the database."
repl.AddSubscription(AddOption.ExistingDatabase)
repl.Synchronize()
I also checked the the connection string and it seems to be fine. Both my device and server can ping each other. Moreever I can also access the Web syncronization folder(on server) from the device.
Is anyone having a resolution for this?The most common is not disposing the replication object or other data related objects. Make sure there isn't any other arround.
Sql Mobile 2005 allows multiple connections except while syncronizing.
Another known cause is a bad path on the connection string.
Other forum entries referring this problem:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=334604&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=478902&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=961633&SiteID=1|||
Hi,
I finally found the solution to this...
repl.AddSubscription(AddOption.ExistingDatabase)
repl.Synchronize()
(Note: I am trying to synchronize on an exisiting database)
The problem was since my database is already in use by my application and I am trying to sync the same DB. Synchronization cannot occur if the connection is already open by the application. Sql Mobile 2005 allows multiple connections except while synchronizing.
Therefore we need to close and dispose the open connection used by the application as under before attempting to synchonize.
(Below is the sample code)
private sub SampleSync()
sharedCon.close
sharedCon.dispose
try
' TO DO: Set replication object properties here
repl.AddSubscription(AddOption.ExistingDatabase)
repl.Synchronize()
finally
repl.dispose
end try
' TO DO: Open your shared connection here if required.
End sub
Note: Most of the times the connection string also causes a problem. A sample connection string would look like this...
repl.SubscriberConnectionString ="\Program Files\YourAppName\YourDb.sdf;Password =<...>"
No comments:
Post a Comment