更新批量数据 [英] updating batches of data

查看:73
本文介绍了更新批量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp .net中使用GridView并使用edit命令字段属性编辑数据(正如我们所知,更新已编辑的行后,我们会自动更新数据库),并且我想使用事务处理(开始提交语句-包括回滚)在单击某些按钮后(例如在发生某些事件之后)在数据库中提交此更新查询,而不是自动将已编辑的数据从网格直接插入或更新到数据库...因此我想将它们保存在临时位置(甚至许多已编辑的行-不仅是一行),然后确认交易-更新数据库中的真实表...

I am using GridView in asp .net and editing data with edit command field property (as we know after updating the edited row, we automatically update the database), and I want to use transactions (with begin to commit statement - including rollback) to commit this update query in database, after clicking in some button (after some events for example), not automatically to insert or update the edited data from grid directly to the DB...so I want to save them somewhere temporary (even many edited rows - not just one row) and then to confirm the transaction - to update the real tables in database...

欢迎任何建议...

我使用了一些很好的链接,但是非常有用,例如: http://www.asp.net/learn/data-访问/tutorial-63-cs.aspx http://www.asp.net/learn/data-访问/tutorial-66-cs.aspx 等等...

I've used some good links, but very helpful, like: http://www.asp.net/learn/data-access/tutorial-63-cs.aspx http://www.asp.net/learn/data-access/tutorial-66-cs.aspx etc...

推荐答案

嗯,

您可以将已编辑的数据存储在会话中的数据表中.然后将此数据表作为批量插入传递到数据库中.有2个选项可供选择

you can store your edited data in a DataTable in session. and then pass this data table as a bulk insert in to the database. 2 options are available for this

  1. 如果您使用的是SQL Server 2005,则可以使用OpenXML实现此目的,正如我所说的
  1. if you are using SQL Server 2005 you can use OpenXML to achieve this, as i have stated here
  2. if you are using SQL Server 2008 youc an use Table Variables like i did here.

我希望对您有帮助

这篇关于更新批量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆