码迷,mamicode.com
首页 > Windows程序 > 详细

c#使用 TransactionScope事务导入数据例程

时间:2016-07-06 11:42:34      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

using System.Transactions;

try
{

using (TransactionScope scope = new TransactionScope())
{


var count = dc.ExecuteCommand(@"insert into bg_count_month(tj_month,emp_id,emp_name,count_month,count_day,money,dw)
select tj_month,emp_id,emp_name,count_month,count_day,money,dw from bg_count_month_import");
Lable_message.Text = "导入记录数:" + count;
dc.ExecuteCommand("delete from bg_count_month_import ");
scope.Complete();

}
GridView2.DataSourceID = "SqlDataSource1";
GridView2.DataBind();
Response.Write(MyUI.javascript_alert(Lable_message.Text));

}

catch (Exception e1)
{
Lable_message.Text = e1.Message;
Response.Write(MyUI.javascript_alert("错误:导入数据错误!"));
}

c#使用 TransactionScope事务导入数据例程

标签:

原文地址:http://www.cnblogs.com/shanwater/p/5646363.html

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