日期:2014-05-17 浏览次数:20411 次
Table1DataContext db = new Table1DataContext(); public Table1 UpdateTable1(int colId, string name) { Table1 t = db.Table1.FirstOrDefault(p=>p.colId==colId); t.colName = name; return t; }
Table1DataContext db = new Table1DataContext(); public void UpdateTable1(Table1 table) { // 以前我都是用下面的代碼進行更新: // Table1 t = db.Table1.FirstOrDefault(p=>p.colId==colId); // t.colName = name; // db.SubmitChanges(); }
Table1DataContext db = new Table1DataContext(); public void UpdateTable1(Table1 table) { // new code like this: Table1 t = db.Table1.FirstOrDefault(p=>p.colId==table.colId); t.colName = table.name; db.SubmitChanges(); }
------解决方案--------------------
public void UpdateTable1(Table1 table) { // 以前我都是用下面的代碼進行更新: Table1 t = db.Table1.FirstOrDefault(p=>p.colId==colId); t.colName =table.name; db.SubmitChanges(); }
------解决方案--------------------