C# 中使用事务的例子
来源:互联网 发布:cda数据分析师试题 编辑:程序博客网 时间:2024/05/22 01:43
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace 事务使用
{
class Program
{
static void Main(string[] args)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "server=.;database=check_card_database;user id = sa;password=19790601";
conn.Open();
SqlTransaction tran = conn.BeginTransaction();
try
{
Console.WriteLine(conn.State.ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update meter_err_info set err_info='上盖被打开了' where user_code='01022038' and meter_num='20131300'";
cmd.Connection = conn;
//SqlTransaction tran = new SqlTransaction();
cmd.Transaction = tran;
Console.WriteLine( cmd.ExecuteNonQuery().ToString());
tran.Commit();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
tran.Rollback();
}
finally
{
conn.Close();
}
Console.ReadLine();
}
}
}
- C# 中使用事务的例子
- C#三层中oracle事务的使用
- C#中OleDb事务小例子
- c#事务例子
- C#语言中TransactionScope类的使用(分布式事务)
- t-sql - 事务使用的简单例子
- C#中练习属性使用的一个例子
- C#中for循环使用的小例子
- c#中抽象类、接口的使用例子
- jdbc事务使用例子
- C#中使用COM+实现事务控制
- c# 进度条的使用(例子)
- c# 进度条的使用(例子)
- sql T_sql 在存储过程中使用事务Trans 例子
- C#中使用ref、out、params例子
- RSA例子在iOS/C#中使用
- SQLHelp中事务的使用
- JDBC中事务的使用
- linux终端上网
- 学习datalist加分页
- 并查集的应用:食物链
- php date()
- TIM Login Failed
- C# 中使用事务的例子
- linux sed命令详解
- MyEclipse8.6安装SVN
- (POJ1844)Sum
- LDAP常见错误对应编码表
- wifi workflow
- 启动一个线程是用run()还是start()? 为什么?
- segment fault 段错误 (core dumped)的起因分析!
- java不使用中间变量交换两个数