Groups | Blog | Home
all groups > sql server replication > august 2005 >

sql server replication : SqlCeReplication.Synchronize() Error - urgent help req'd!


steroche
8/20/2005 5:22:19 PM
I have been having this problem for ages now and i dont know where i am
going wrong!!!I am running the following NorthwindCE sample
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/sqlcemergereplication.aspx
and i am getting the following error "Message: Some Distributor
properties are not specified[,,,,,] Native Error: 28507
I have stepped through the code and it appears to be catching the error
at the SqlCeReplication.Syncronize() call.
I am very new to SQLCE and merge replication but as i understand it i
have performed all the necessary steps. I have created a new
publication of the Northwind DB from the SQL Server Enterprise Manager
and set up a snapshot share on my drive (the drive is NTFS).
The only obvious place where i can see is that i am after placing
incorrect values in the form to start with. The following is what i
have:

Publisher: MyPC
Publication Name: Northwind_merpub
Database Name: Northwind
InternetURL: http://MyPC/snapshot_folder_share
Subscription Name: Pocket_PC
Local File Name NorthwindCE

Anybody know if this is correct or where i am going wrong?

Thanks,
Stephen
steroche
8/20/2005 7:02:14 PM
Thanks for the reply.
I just read on MSDN that i should specify the distrib securitymode so i
did and nothing happened but i will go ahead and set the other
distributor properies now and see if that works.
In the meantime here's my code:

private void btnSynchronize_Click(object sender, System.EventArgs e)
{
SqlCeReplication repl = null;

//Declare a variable to record if exceptions were thrown.
bool exceptionOccured = false;
try
{
//Present the WaitCursor, disable the button.
Cursor.Current = Cursors.WaitCursor;
btnSynchronize.Enabled = false;

repl = new SqlCeReplication();

//Set the properties using data from the UI.
repl.DistributorSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;

repl.Publisher = txtPublisher.Text;
repl.PublisherLogin = txtUserID.Text;
repl.PublisherPassword = txtPassword.Text;
repl.InternetUrl = txtInternetURL.Text;
repl.InternetLogin = txtInternetID.Text;
repl.InternetPassword = txtInternetPassword.Text;
repl.Subscriber = txtSubscription.Text;
repl.Publication = txtPublication.Text;
repl.PublisherDatabase = txtDatabase.Text;
strDataSource = txtFileName.Text;
ssceConn.ConnectionString = "Data Source =" + strDataSource;
repl.SubscriberConnectionString =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=" +
strDataSource;

//If the file doesn't exist, create it and add it as a
subscription.
while (System.IO.File.Exists(strDataSource) == false)
{
if(MessageBox.Show("The file " + strDataSource + " does not exist,
do you want to create it?",
"Merge",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1)
== DialogResult.Yes)
{
repl.AddSubscription(AddOption.CreateDatabase);
this.Refresh();
}
}

//Perform the synchronization.
repl.Synchronize();//ERROR HERE

//Display results of the synchronization.
MessageBox.Show("Synchronization Complete: \n" +
"Publisher changes = " + repl.PublisherChanges.ToString() +
"\nPublisher conflicts = " + repl.PublisherConflicts.ToString() +
"\nSubscriber changes = " + repl.SubscriberChanges.ToString(),
"Replication", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,
MessageBoxDefaultButton.Button1);
}
catch(SqlCeException err) //ERROR CAUGHT HERE
{
MessageBox.Show("Message: " + err.Message.ToString() +
"\nNative Error: " + err.NativeError.ToString(), "Replication",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
//Add error handling code here.
exceptionOccured = true;
}
catch (Exception err)
{
//Add error handling code here.
exceptionOccured = true;
}
finally
{
//Enable the Button, dispose of the Replication object.
btnSynchronize.Enabled = true;
repl.Dispose();

if(exceptionOccured == false)
btnBind.Enabled = true;

//Remove the WaitCursor.
Cursor.Current = Cursors.Default;
}
}
steroche
8/20/2005 7:33:26 PM
Damn!!Didn't work!
I'm all out - i don't have a clue where i'm going wrong and ive been at
this about 5 hours now!
I am still getting the same error in the same place: Message: Some
Distributor
properties are not specified[,,,,,] Native Error: 28507

I got rid of the need for inputting of the
internetLogin,internetPassword,PublisherLogin and PublisherPassword as
im using anonymous access throughout.

Here's my code as it is now:
private void btnSynchronize_Click(object sender, System.EventArgs e)
{
SqlCeReplication repl = null;

//Declare a variable to record if exceptions were thrown.
bool exceptionOccured = false;
try
{
//Present the WaitCursor, disable the button.
Cursor.Current = Cursors.WaitCursor;
btnSynchronize.Enabled = false;

repl = new SqlCeReplication();

//Set the properties using data from the UI.
repl.DistributorSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;

repl.PublisherSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;
repl.Publisher = txtPublisher.Text;

repl.InternetUrl = txtInternetURL.Text;

repl.Subscriber = txtSubscription.Text;
repl.Publication = txtPublication.Text;
repl.PublisherDatabase = txtDatabase.Text;
strDataSource = txtFileName.Text;
ssceConn.ConnectionString = "Data Source =" + strDataSource;
repl.SubscriberConnectionString =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=" +
strDataSource;

//If the file doesn't exist, create it and add it as a
subscription.
while (System.IO.File.Exists(strDataSource) == false)
{
if(MessageBox.Show("The file " + strDataSource + " does not exist,
do you want to create it?",
"Merge",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1)
== DialogResult.Yes)
{
repl.AddSubscription(AddOption.CreateDatabase);
this.Refresh();
}
}

//Perform the synchronization.
repl.Synchronize();

//Display results of the synchronization.
MessageBox.Show("Synchronization Complete: \n" +
"Publisher changes = " + repl.PublisherChanges.ToString() +
"\nPublisher conflicts = " + repl.PublisherConflicts.ToString() +
"\nSubscriber changes = " + repl.SubscriberChanges.ToString(),
"Replication", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,
MessageBoxDefaultButton.Button1);
}
catch(SqlCeException err)
{
MessageBox.Show("Message: " + err.Message.ToString() +
"\nNative Error: " + err.NativeError.ToString(), "Replication",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
//Add error handling code here.
exceptionOccured = true;
}
catch (Exception err)
{
//Add error handling code here.
exceptionOccured = true;
}
finally
{
//Enable the Button, dispose of the Replication object.
btnSynchronize.Enabled = true;
repl.Dispose();

if(exceptionOccured == false)
btnBind.Enabled = true;

//Remove the WaitCursor.
Cursor.Current = Cursors.Default;
}
}
}


Any ideas?????
Hilary Cotter
8/20/2005 9:51:31 PM
Please post your code.

I think you will need to specify Distributor, DistributorSecurityMode, and
perhaps DistributorAccount and DistributorPassword.

--
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html

Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
[quoted text, click to view]

steroche
8/21/2005 1:35:25 PM
Somebody help!!Deadline is looming and having no success with this
SQLCE Merge Rep.
OK, now i am getting an error: Message: Native Error : -1. I have
searched thoroughly and i cannot get a hit for this error code. This is
so frustrating!
Thought i might have solved the problem by adding a subscription in the
Enterprise Manager which i forgot to do but that made no difference.
Here's my code now - somebody please help!!!

private void btnSynchronize_Click(object sender, System.EventArgs e)
{
SqlCeReplication repl = null;

//Declare a variable to record if exceptions were thrown.
bool exceptionOccured = false;
try
{
//Present the WaitCursor, disable the button.
Cursor.Current = Cursors.WaitCursor;
btnSynchronize.Enabled = false;

repl = new SqlCeReplication();

//Set the properties using data from the UI.
repl.DistributorSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;
repl.DistributorAddress = null;
repl.Distributor = null;
repl.DistributorNetwork =
System.Data.SqlServerCe.NetworkType.DefaultNetwork;
repl.DistributorLogin = null;
repl.DistributorPassword = null;

repl.PublisherSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;
repl.Publisher = txtPublisher.Text;
repl.Publication = txtPublication.Text;
repl.PublisherLogin = null;
repl.PublisherPassword = null;
repl.PublisherDatabase = txtDatabase.Text;

repl.InternetUrl = txtInternetURL.Text;
repl.InternetLogin = null;
repl.InternetPassword = null;

repl.Subscriber = txtSubscription.Text;



strDataSource = txtFileName.Text;
ssceConn.ConnectionString = "Data Source =" + strDataSource;
repl.SubscriberConnectionString =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=" +
strDataSource;

//If the file doesn't exist, create it and add it as a
subscription.
while (System.IO.File.Exists(strDataSource) == false)
{
if(MessageBox.Show("The file " + strDataSource + " does not exist,
do you want to create it?",
"Merge",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1)
== DialogResult.Yes)
{
repl.AddSubscription(AddOption.CreateDatabase);
this.Refresh();
}
}

//Perform the synchronization.
repl.Synchronize();

//Display results of the synchronization.
MessageBox.Show("Synchronization Complete: \n" +
"Publisher changes = " + repl.PublisherChanges.ToString() +
"\nPublisher conflicts = " + repl.PublisherConflicts.ToString() +
"\nSubscriber changes = " + repl.SubscriberChanges.ToString(),
"Replication", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,
MessageBoxDefaultButton.Button1);
}
catch(SqlCeException err)
{
MessageBox.Show("Message: " + err.Message.ToString() +
"\nNative Error: " + err.NativeError.ToString(), "Replication",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
//Add error handling code here.
exceptionOccured = true;
}
catch (Exception err)
{
//Add error handling code here.
exceptionOccured = true;
}
finally
{
//Enable the Button, dispose of the Replication object.
btnSynchronize.Enabled = true;
repl.Dispose();

if(exceptionOccured == false)
btnBind.Enabled = true;

//Remove the WaitCursor.
Cursor.Current = Cursors.Default;
}
}


And these are the values i am entering:

Publisher: MyServer
Publication Name: Northwind_merpub
Database Name: MyServer/Northwind
InternetURL: http://MyServer/SmartDeviceApplication3/sscesa20.dll
Subscription Name: Pocket_PC
Local File Name Northwind_CE.sdf

I am using a PPC2003 emulator, IIS5.1, SQLCEsp3, SQL200sp3 and
developing through VS2003.Net EnAr.
Whats even more frustrating is the lack of complete SQLCE Merge
Replication samples on the internet - i have been only able to locate
the NorthwindCE one which i cant get to work!

I have a basic question somebody might be able to help me with - my
undertanding of SQL Merge Replication is this
- I have my db set up in SQL2000
- need to create a publication and subscription in the Enterprise
Manager
-create a Virtual Directory with the sscesa20.dll in it through the
SQLCE Connectivity Management snapin
- need to create a blank .sdf db on the device (emulator)
-then need to specify publisher, distributor values on the emulator
-then call .Synchronise() and all the data from the publisher is pushed
onto(merged) onto the CE database in the correct format

Is this correct???
Thanks in advance
Stephen
steroche
8/21/2005 3:16:49 PM
OK panic over :)
I figured out some of my parameters were in correct.I have commented
out the incorrect lines in case anybody else comes across this
problem
private void btnSynchronize_Click(object sender, System.EventArgs e)
{
SqlCeReplication repl = null;
//Declare a variable to record if exceptions were thrown.
bool exceptionOccured = false;
try
{
//Present the WaitCursor, disable the button.
Cursor.Current = Cursors.WaitCursor;
btnSynchronize.Enabled = false;
repl = new SqlCeReplication();

repl.DistributorNetwork =
System.Data.SqlServerCe.NetworkType.DefaultNetwork;
repl.DistributorSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;
//repl.DistributorAddress = System.Data.SqlServerCe.;
repl.Distributor = txtPublisher.Text;
//repl.DistributorLogin = null;
//repl.DistributorPassword = null;

repl.PublisherSecurityMode =
System.Data.SqlServerCe.SecurityType.NTAuthentication;
repl.Publisher = txtPublisher.Text;
repl.Publication = txtPublication.Text;
//repl.PublisherLogin = null;
//repl.PublisherPassword = null;
repl.PublisherDatabase = txtDatabase.Text;

repl.InternetUrl = txtInternetURL.Text;
//repl.InternetLogin = null;
//repl.InternetPassword = null;

repl.Subscriber = txtSubscription.Text;

strDataSource = txtFileName.Text;
ssceConn.ConnectionString = "Data Source =" + strDataSource;
repl.SubscriberConnectionString =
"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=" +
strDataSource;

//If the file doesn't exist, create it and add it as a subscription.
while (System.IO.File.Exists(strDataSource) == false)
{
if(MessageBox.Show("The file " + strDataSource + " does not exist,
do you want to create it?",
"Merge",MessageBoxButtons.YesNo,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1)
== DialogResult.Yes)
{
repl.AddSubscription(AddOption.CreateDatabase);
this.Refresh();
}
}
//Perform the synchronization.
repl.Synchronize();

//Display results of the synchronization.
MessageBox.Show("Synchronization Complete: \n" +
"Publisher changes = " + repl.PublisherChanges.ToString() +
"\nPublisher conflicts = " + repl.PublisherConflicts.ToString() +
"\nSubscriber changes = " + repl.SubscriberChanges.ToString(),
"Replication", MessageBoxButtons.OK, MessageBoxIcon.Asterisk,
MessageBoxDefaultButton.Button1);
}
catch(SqlCeException err)
{
MessageBox.Show("Message: " + err.Message.ToString() +
"\nNative Error: " + err.NativeError.ToString(), "Replication",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
//Add error handling code here.
exceptionOccured = true;
}
catch (Exception err)
{
//Add error handling code here.
exceptionOccured = true;
}
finally
{
//Enable the Button, dispose of the Replication object.
btnSynchronize.Enabled = true;
repl.Dispose();

if(exceptionOccured == false)
btnBind.Enabled = true;

//Remove the WaitCursor.
Cursor.Current = Cursors.Default;
}
}


I am using integrated windows login.
However my previous question remains - are my Merge Replication
assumptions correct?
One thing that does baffle me is where my .SDF file goes after its
created? I can't find it on my emulator or on the server - i just
wanted to query the table using the SQLCE Query analyser to verify the
data merge worked
AddThis Social Bookmark Button