开发者

Local Database Loses Changes After Build

开发者 https://www.devze.com 2023-01-26 05:34 出处:网络
string connectionString = \"Data Source =|DataDirectory|\\\\user.sdf\"; User context = new User(connectionString);
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

精彩评论

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