المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Create database in windows mobile but dont create password



C# Programming
06-30-2009, 08:53 AM
Create database in windows mobile but when i run doesn't create password so exception for password mismatch.If i Create database in windows mobile it works fine...

How solve it...
Plz Help me . this is my first project of windows mobile.
Code is given below:

DataTable dt = new DataTable("ServerSettings");
dt.ReadXmlSchema(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().G etName().CodeBase) + ("\\ServerInformation.bin"));
dt.ReadXml(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName ().CodeBase) + ("\\ServerInformation.bin"));


SqlCeReplication repl = new SqlCeReplication();

repl.InternetUrl = @"http://" + dt.Rows[0]["PCName"].ToString() +"/DBRestaurant/sqlcesa30.dll";
repl.Publisher = dt.Rows[0]["PCName"].ToString();
repl.PublisherDatabase = @"DBRestaurant";
repl.PublisherSecurityMode = SecurityType.DBAuthentication;
repl.PublisherLogin = @"sa";
repl.PublisherPassword = dt.Rows[0]["PublicatrionPassword"].ToString();
repl.Publication = @"DBRestaurant";
repl.Subscriber = @"DBRestaurant";
repl.SubscriberConnectionString = @"Data Source=""My documents\DBRestaurant.sdf"";Password=" + dt.Rows[0]["SubscriptionPassword"].ToString() + ";Max Database Size=128;Default Lock Escalation =100;";

try
{

if(!System.IO.File.Exists("My documents\\DBRestaurant.sdf"))
repl.AddSubscription(AddOption.CreateDatabase);
repl.Synchronize();
}
catch (SqlCeException e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
}