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

مشاهدة النسخة كاملة : Databe create by Programmatically but Password not create



C# Programming
06-30-2009, 09:30 AM
I try to develop windows mobile application. Pro grammatically i create database but it does not crate password. so it show password mismatch.

Plz help me this is my first windows mobile application...

My 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());
}