I build a RDA example and it is very usefull...
[Remote Data Access Synchronization with SQL Server 2005]
Pull operation sample:
private void btnRDAPull_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
// upgrade for using SQL CE 3.5
//try
//{
// SqlCeEngine sqe = new SqlCeEngine(CONNECTIONSTRING_MOBILE);
// sqe.Upgrade();
//}
//catch { }
try
{
// Initialize the RDA object.
using (SqlCeRemoteDataAccess rda = new SqlCeRemoteDataAccess())
{
//rda.InternetLogin = "XXXXXXXXXX";
//rda.InternetPassword = "XXXXXXXXXXX";
rda.InternetUrl = "http://XXXXXXXXXXXX/samimobiletest/sqlcesa35.dll";
//rda.LocalConnectionString = "Data Source=\\DB.sdf;Password =XXXXX;";
rda.LocalConnectionString = CONNECTIONSTRING_MOBILE;
rda.Pull(
"Users",
//"Select UserId,UserName,Password from Users",
"Select * from Users",
CONNECTIONSTRING_SERVER,
RdaTrackOption.TrackingOnWithIndexes);
}
MessageBox.Show("Pull OK :)");
}
catch (SqlCeException scEx)
{
//Use your own error handling routine.
MessageBox.Show(scEx.Message);
//ShowErrors(e)
}
finally
{
Cursor.Current = Cursors.Default;
}
}
Push operation sample:
private void btnRDAPush_Click(object sender, EventArgs e)
{
try
{
// Initialize the RDA object.
using (SqlCeRemoteDataAccess rda = new SqlCeRemoteDataAccess())
{
//rda.InternetLogin = "XXXXX";
//rda.InternetPassword = "XXXXXXXX";
rda.InternetUrl = "http://XXXXXXXXXX/samimobiletest/sqlcesa35.dll";
rda.LocalConnectionString = CONNECTIONSTRING_MOBILE;
rda.Push("Users", CONNECTIONSTRING_SERVER, RdaBatchOption.BatchingOff);
}
// show message
MessageBox.Show("Push OK :)");
}
catch (SqlCeException scEx)
{
// Use your own error handling routine.
MessageBox.Show(scEx.Message);
}
}
here is a link for download:
Download full example
No comments:
Post a Comment