All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET定制错误处理页面_[Asp.Net教程]
Sql2000和Sql2005共存安装详细过程_[SQL Server教程]
C#中定义鼠标指针为指定的动画图标实例
XML入门教程-验证XML是合法的XML_[XML教程]
JavaScript变换图片的几种方法_JavaScript技术_编程技术
SQL循序渐进(11)GROUP,BY子句_[SQL,Server教程]
JS开发字典探测用户名或密码工具_JavaScript技术_编程技术
效果不错的PHP分页类代码_[PHP教程]
ajax和asp.net的配置文件_.net资料_编程技术
HTML-加速、再加速_[Html教程]
Reading number is top 10 pictures
Wild animals melee moment of life and death1
The woman fight much more than men
No trading, no killing
Household design comfortable contracted
A man's favorite things15
网络游戏与脑残
The money of more than 100 countries and regions3
2015中美最新武器装备巅峰对决!
刘亦菲写真集2
Japan sexy beauty passion photo
Download software ranking
Sora aoi‘s film--Lust fan wall
Boxer's Top ten classic battle1
星际争霸1.08硬盘免安装版
matrix2
软件工程思想
都市狐狸姑娘传
Desire a peach blossom
The hero
Tram sex maniac 2 (H) rar bag19
Ashlynn Video1
delv published in(发表于) 2014/1/6 9:16:00 Edit(编辑)
通过ADO.NET实现事务处理_[Asp.Net教程]

通过ADO.NET实现事务处理_[Asp.Net教程]

通过ADO.NET实现事务处理_[Asp.Net教程]

在数据库连接上创建事务处理对象,然后调用事务处理对象来提交事务或回滚事务。简单的代码:

private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=192.168.2.200;uid=sa; password=;database = HaierHR");
conn.Open();
//启用事务
SqlTransaction tran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.Transaction = tran;
try
{
cmd.CommandText = "UPDATE HRRollMain Set TotalMember=TotalMember-100 WHERE RollID = '2005070101'";
cmd.ExecuteNonQuery();
cmd.CommandText = "UPDATE HRRollSum Set TotalSumMember=TotalSumMember+100 WHERE RollSumID = '20050701'";
cmd.ExecuteNonQuery();
tran.Commit();
MessageBox.Show("事务提交成功!");
}
catch(Exception ex)
{
tran.Rollback();
MessageBox.Show("Error!"+ex.Message);
}
}


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.