Rollback()为什么不起作用

SqlConnection myConn = new SqlConnection(connectionString);

myConn.Open();

SqlCommand myComm = new SqlCommand();

SqlTransaction myTran = myConn.BeginTransaction();

try

{

myComm.Connection = myConn;

myComm.Transaction = myTran;

myComm.CommandText = "Insert Into LogonOut (LO_Name,LO_Time) Values('11aaa1xxx','2008-1-1')";

myComm.ExecuteNonQuery();//提交事务

//myTran.Save("NoUpdate");

myComm.CommandText = "update LogonOut set LO_Name = 'aaa123' where lo_id = '3d'";

myComm.ExecuteNonQuery();//提交事务

//myComm.CommandText = "CREATE database TestDB";

//myComm.ExecuteNonQuery();//提交事务

}

catch (Exception err)

{

myTran.Rollback();

TextBox1.Text = "TextBox1" + err.Message;

myConn.Close();

return;

}

myTran.Commit();

myConn.Close();