Local Database Loses Changes After Build
string connectionString =
     "Data Source =|DataDirectory|\\user.sdf";
User context = new User(connectionString);
Userdetail newUser = new Userdetail();
newUser.Username = txtReg.Text;
newUser.Password = txtRegPassword1.Password;
try
{
    context.Userdetail.InsertOnSubmit(newUser);
    context.SubmitChanges();
}
catch (ChangeConflictException)
{
  context.ChangeConflicts.ResolveAll(System.Data.Linq.RefreshMode.KeepChanges);
}
I want to add the new row of data (username, password) into the existing database but unfortunately it gets added temporarily only. As soon as the program is closed,开发者_JS百科 the database is reverted to what it was.. Any help would be highly appreciated
Have you seen this: Why isn't my SubmitChanges() working in LINQ-to-SQL?
Im assuming you're using Linq to Sql.
Linq to Entities would be: context.SaveChanges();
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论