![]() |
#2
qqpet2017-10-14 21:50
|
只有本站会员才能查看附件,请 登录
使用此方法更新:

SqlConnection conn = (SqlConnection)GetConnection();
SqlCommand cmd = new SqlCommand(string.Format("select top 0 * from {0}", dt.TableName), conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
sda.Update(dt);
sda.Update(dt);SqlCommand cmd = new SqlCommand(string.Format("select top 0 * from {0}", dt.TableName), conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
SqlCommandBuilder scb = new SqlCommandBuilder(sda);
sda.Update(dt);
独立更新一条记录没有问题,完全可以实现。
只有本站会员才能查看附件,请 登录
无重叠多条记录,一次性更新也没问题。
只有本站会员才能查看附件,请 登录
但是如果是这种情况(改前与改后存在主键重叠记录)就无法成功,不报任何错误。
谁能告诉我为什么,如果有解决方案就更好了?谢谢