SqlConnection conn = DbopUtil.GetConn();
SqlTransaction tran = conn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.Transaction = tran;
try
{
....sql语句
tran.commit();
}
catch
{
tran.Rollback();
conn.close();
throw;
}然后再下面
try
{
conn.open();
....sql语句
tran.commit();
}
catch
{
tran.Rollback();
conn.close();
throw;
}
下面这个有没有用的?
SqlTransaction tran = conn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.Transaction = tran;
try
{
....sql语句
tran.commit();
}
catch
{
tran.Rollback();
conn.close();
throw;
}然后再下面
try
{
conn.open();
....sql语句
tran.commit();
}
catch
{
tran.Rollback();
conn.close();
throw;
}
下面这个有没有用的?
解决方案 »
- FlashPrinter转换错误
- 在win2003中发布asp.net的网站,运行中出现问题
- 进销存及帐务系统的设计问题
- A underlying connection was closed: A connection that was expected to be kept alive was closed by the server
- Datagrid根据内容改变单元格颜色问题?
- 100分请教解压缩问题
- 在asp.net网站中把数据分类汇总后还要打印(多页),请问各位有什么方案?
- 请教DataGrid控件的一个问题
- 为什么不能创建新web应用程序
- 动态添加控件
- ASP.NET+简单三层架构+WebService+JS
- ASP.NET图片前台显示的问题
SqlTransaction tran = conn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.Transaction = tran;
try
{
....sql语句
tran.commit();
}
catch
{
tran.Rollback();
throw;
}
finally
{
conn.close();
}然后再下面
conn.open();
SqlTransaction tran1 = conn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
cmd.Transaction = tran1;
try
{
conn.open();
....sql语句
tran.commit();
}
catch
{
tran1.Rollback();
throw;
}
finally
{
conn.close();
}
恩,这我知道,但是我现在就是有一个要做一个程序,这个页面,本地订单下单的有3句SQL语句同时执行,然后下面有个退款的4句SQL语句同时执行,这样就是要定义两个事务了吧,上面的提交了就提交,不能重复使用吗?