我创建了一个sqlconnection,CN1。然后这个CN1被打开。稍后在代码中有一个事务范围。如果我在这个 CN1 连接上执行一个 sql 命令,这是在事务中吗?
代码如下所示;
SqlConnection cn1 = new SqlConnection();
cn1.Open(); //connection opened when there is no ambient transaction.
...
using(TransactionScope scope = new TransactionScope())
{
SqlCommand cmd; //a typical sql command.
...
cmd.ExecuteNonQuery(); //Is this command within transaction?
...
}