SQL批量提交修改业务

把你需要批量提交修改的东西在内存中修改完毕 然后执行以下代码

SqlConnection conn = new SqlConnection(ConnectionString);
SqlDataAdapter sda = new SqlDataAdapter("select Id,RankSummary,RankOfCn,Classify from u_College;", conn);

//这里的SQL语句可以是查询你修改的那张表的语句

//比如你Update这张表 这里的SQL语句就可以是Select * from 表 这样的
SqlCommandBuilder updateall = new SqlCommandBuilder(sda);
sda.Update(dt);//.NET提供的批量修改操作
dt.AcceptChanges();//必须先upda再去AcceptChanges  虽然不知道为什么 2333

猜你喜欢

转载自www.cnblogs.com/CurtilageBoy/p/8982032.html