SQL Server 2005 and SQL Mobile 2005 Replication

G

Guest

For some reason replication is not releasing the Database. In order to
continue I have to reboot the device or emulator.
Check out the following code and advice.
Thanks

public void ReplSync(bool init)
{
Utils utils = new Utils();
SqlCeReplication repl = new SqlCeReplication();
string localConn = @"Data Source=" + utils.GetCurrentDirectory() +
@"\Database\Mobiletech.sdf";
string internetUrl = @"http://192.168.1.13/VersionControl/sqlcesa30.dll";
string internetLogin = "222";
string internetPassword = "222222";

repl.InternetUrl = internetUrl;
repl.InternetLogin = internetLogin;
repl.InternetPassword = internetPassword;

/// Set Publisher properties.
///
repl.Publisher = "msmithlaptop";
repl.PublisherDatabase = "MTS";
repl.Publication = "MTSMaster";

/// Set Publisher security properties.
///
repl.PublisherSecurityMode = SecurityType.NTAuthentication;
repl.PublisherLogin = internetLogin;
repl.PublisherPassword = internetPassword;

/// Set Subscriber properties.
///
repl.SubscriberConnectionString = localConn;
repl.Subscriber = "Driver1";

/// Add dynamic filter (filter by Driver IDs).
///
repl.HostName = "1";

/// Bidirectional or upload only?
///
repl.ExchangeType = ExchangeType.BiDirectional;

try
{
if (init == true)
{
/// Create the local database subscription.
///
repl.AddSubscription(AddOption.CreateDatabase);
}
repl.Synchronize();
}
catch (Exception ex)
{

}
finally
{
}
if (init == true)
{
try
{
repl.Publication = "MTSTrans";
repl.AddSubscription(AddOption.ExistingDatabase);
repl.Synchronize();
}
catch (Exception ex)
{

}
finally
{
}
try
{
repl.Publication = "MTSOther";
repl.AddSubscription(AddOption.ExistingDatabase);
/// Synchronize to the SQL Server 2000 database to populate the local
subscription database.
///
repl.Synchronize();
}
catch (Exception ex)
{

}
finally
{
}
}

/// Dispose of the Replication object.
///
repl.Dispose();

}
}
 
D

Darren Shaffer

get rid of your repl.Dispose() statement - it causes problems for me too and
it's
related to beta versions of CF. let the GC handle it instead.

--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top