【发布时间】:2013-08-09 10:46:26
【问题描述】:
我在通过 linq 更新表时遇到问题。
我为它执行以下代码
tbl_Customer tblcust= new tbl_Customer();
tbl_Customer tcust = obj.tbl_Customers.Single(c => c.C_ID == 1);
tblcust.C_Name = txtcname.Text;
tblcust.C_Address = txtcaddress.Text;
tblcust.C_Mobile =Convert.ToInt64( txtcmobile.Text);
obj.SubmitChanges();
但是这段代码不会影响表中的记录。我使用外部 SQL Server 连接数据库,帮我解决这个问题。
【问题讨论】:
-
我认为您应该为 tcust 而不是 tblcust 分配值,这是一个新对象
标签: c# sql-server linq sql-update