开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜