SQL Replication

A

Atley

I seem to have missed something.

I am using the code straight from the example on the site:

Dim repl As System.Data.SqlServerCe.SqlCeReplication = Nothing
Try
' Set the Replication object.
repl = New System.Data.SqlServerCe.SqlCeReplication
repl.InternetUrl = http://192.168.1.13/moviebase/sscesa20.dll
repl.InternetLogin = "MyCEMachine"
repl.InternetPassword = "connectivity"
repl.Publisher = "\\ariassvr"
repl.PublisherDatabase = "clientbase"
repl.PublisherLogin = "MyCEMachine"
repl.PublisherPassword = "connectivity"
repl.Publication = "clientbase"
repl.SubscriberConnectionString =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\testce.sdf"
repl.Subscriber = "MyPDA"

' Synchronize to the instance of SQL Server 2000 to populate the
Subscription.
repl.Synchronize()

Catch e As System.Data.SqlServerCe.SqlCeException

' Use your own error handling routine to show error information.
'ShowErrors(e)
MsgBox(e.ToString)

Finally

' Dispose of the Replication object.

repl.Dispose()

End Try



I must be missing something simple... I just don't seem to be getting
this... I get a SqlCeException error each time I run this... I am not
getting an error message that I can use... Any help would be greatly
appreciated.

Atley
 
M

Michael Morisoli

Atley, here is a code snypit that works great for me.

The key is to have your replication setup on SQL Server and IIS as well.

Hope it helps. Oh this is C#.

Mike


/// <summary>
/// Create local database, then syncronize the data.
/// </summary>
public bool CreateDatabase()
{
WaitCursor.Show(true);
bool retval = true;
SqlCeReplication engine = null;
m_errors = ""; // Reset the error string.

try
{
// first, close and then delete existing database
Close();
DeleteDatabase();

// create new database
engine = new SqlCeReplication();
engine.SubscriberConnectionString = this.ConnectionString;
engine.AddSubscription(AddOption.CreateDatabase);
engine.Dispose();

// Syncronize the database.
engine = new SqlCeReplication();
engine.InternetUrl =
"http://vieon-dev-01/receivingrda/sscesa20.dll";
engine.InternetLogin = "<your name>"; // This is your Basic
Authentication username
engine.InternetPassword = "<your password>"; // This is your
Basic Authentication password
engine.Publisher = "vieon-dev-01"; // This is the name of the
server running SQL Server
engine.PublisherDatabase = "Receiving"; // This is the name of
the actual database that you're publishing
engine.PublisherLogin = "sa"; // This is your SQL Server
username
engine.PublisherPassword = "<your sa password>"; // This is
your SQL Server password
engine.Publication = "Receiving"; // This is the name that
you give to your publication during the wizard setup
engine.Subscriber = "Mike's iPaq"; // This anonymous
subscriber name can be anything you want it to be
engine.SubscriberConnectionString = this.ConnectionString;
//engine.Initilize();
engine.Synchronize();
}
catch (SqlCeException sqlex)
{
retval = false;
HandleError(sqlex);
}
catch (Exception ex)
{
retval = false;
HandleError(ex);
}
finally
{
engine.Dispose();
WaitCursor.Show(false);
}
return retval;
}
 
A

Antares

To know what is missing, you must make a better use of
Try ... Catch.
Use the ex.message to know the error description and
ex.number that help you to find other informations about
the error.
 

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