在Sql Server數據庫中創建了一張表,學號設置了主鍵,在修改的時候報錯,運行到submitchanges的時候運行報錯了,說有主鍵,不能修改,想達到的功能是主鍵對應的Textbox.Text不能修改,只修改其它的數據,用的是LinQ技術,謝謝
LJQLDataContext dc = new LJQLDataContext();
user u = new user();
u.uID = this.txtID.Text.Trim();
u.uName = this.txtName.Text.Trim();
u.uSix = this.txtSix.Text.Trim();
u.uPassword = this.txtPassword.Text.Trim();
dc.user.InsertOnSubmit(u);
dc.SubmitChanges();
load();
請幫忙完善一下
user u = new user();
u.uID = this.txtID.Text.Trim();
->
user u = dc.user.Single(x => x.uID == this.txtID.Text.Trim());
去掉
dc.user.InsertOnSubmit(u);