码迷,mamicode.com
首页 > 数据库 > 详细

SqlBulkCopy批量更新数据库表用例

时间:2017-07-25 18:09:11      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:options   name   nec   nmap   mapping   ota   tab   cti   write   

 using (SqlBulkCopy sqlbulkcopy = new SqlBulkCopy(da.Connection as SqlConnection, SqlBulkCopyOptions.Default, tran as SqlTransaction))
                    {
                        sqlbulkcopy.BatchSize = entityList.Count;
                        sqlbulkcopy.DestinationTableName = TableName;
                        DataTable rightsTable = entityList.ToTable();
                        for (int i = 0; i < rightsTable.Columns.Count; i++)
                        {
                            sqlbulkcopy.ColumnMappings.Add(rightsTable.Columns[i].ColumnName, rightsTable.Columns[i].ColumnName);
                        }
                        sqlbulkcopy.WriteToServer(rightsTable);
                    }

SqlBulkCopy批量更新数据库表用例

标签:options   name   nec   nmap   mapping   ota   tab   cti   write   

原文地址:http://www.cnblogs.com/ccmsalome/p/7235410.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!