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);
}
我想将新的数据行(用户名,密码)添加到现有数据库中,但遗憾的是它只是暂时添加。一旦程序关闭,数据库就会恢复原状。任何帮助都将受到高度赞赏
答案 0 :(得分:0)
你见过这个: Why isn't my SubmitChanges() working in LINQ-to-SQL?
我假设你正在使用Linq到Sql
Linq to Entities将是:context.SaveChanges();