将最美的计算机软件奉献给社会

博客园 首页 新随笔 联系 订阅 管理

//修改数据
    protected void EditData()
    {
        DataContext dbContext = new DataContext("data Source=192.168.0.66;database=LSS1;user id=sa;pwd=xit");
        Table<User> users = dbContext.GetTable<User>();

        var result = from user in users
                     where user.UserName == this.txtUserName.Text.Trim()
                     select user;

        foreach (User u in result)
        {
            u.Age = Convert.ToInt32(this.txtNewAge.Text.Trim().ToString());
        }

        dbContext.SubmitChanges();

    }

posted on 2010-09-25 17:28  赖顺生  阅读(4445)  评论(0编辑  收藏  举报