C# code功能:public string SaveReviseInfo(XmlDocument xmldoc) { SqlCommand sqlcommand = sqlhelper.GetTranSqlCommand(sqlhelper.SqlDBConnectionString); try { XmlNamespaceManager nsmgr = XmlHelper.GetNamespaceManager_rsz(xmldoc.NameTable); XmlElement lEm; XmlNodeList RowNodes; RowNodes = xmldoc.SelectNodes("//root/ReviseInfo", nsmgr); string SqlStr = ""; string EditMode = ""; SqlParameter[] paras = null; for (int i = 0; i < RowNodes.Count; i++) { lEm = (XmlElement)RowNodes[i]; //EditMode=0:初始(加载数据库原有资料行) 1:新增 2:修改 3:删除 EditMode = lEm.GetAttribute("EditMode"); if (EditMode == "0") { } else if (EditMode == "1") { } else if (EditMode == "2") { } else if (EditMode == "3") { } SqlStr = "SELECT RowsCount=COUNT(1) FROM [SP_Revise] WHERE [Code]=@Code"; paras = new SqlParameter[] { new SqlParameter("@Code", lEm.GetAttribute("Code")) }; int obj = (int)sqlhelper.ExecuteScalar(sqlcommand, CommandType.Text, SqlStr, paras); if (obj > 0) { SqlStr = "INSERT INTO [SP_Revory] SELECT * FROM [SP_Revise] WHERE [Code]=@Code;DELETE [SP_Revise] WHERE [Code]=@Code"; paras = new SqlParameter[] { new SqlParameter("@Code", lEm.GetAttribute("Code")) }; sqlhelper.ExecuteNonQuery(sqlcommand, CommandType.Text, SqlStr, paras); } SqlStr = "INSERT INTO [SP_Revise]([Code],[CType],[Name],[Location],[Category],[Suppliers],[BuyTime],[Status],[Deploy],[AdminCD],[AdminNM],[Guid],[Modify],[ModifyNM],[NewTime],[UserNo],[UserNM]) VALUES(@Code,@CType,@Name,@Location,@Category,@Suppliers,@BuyTime,@Status,@Deploy,@AdminCD,@AdminNM,@Guid,@Modify,@ModifyNM,@NewTime,@UserNo,@UserNM)"; paras = new SqlParameter[] { new SqlParameter("@Code",lEm.GetAttribute("Code")), new SqlParameter("@CType",lEm.GetAttribute("CType")), new SqlParameter("@Name",lEm.GetAttribute("Name")), new SqlParameter("@Location",lEm.GetAttribute("Location")), new SqlParameter("@Category",lEm.GetAttribute("Category")), new SqlParameter("@Suppliers",lEm.GetAttribute("Suppliers")), new SqlParameter("@BuyTime",lEm.GetAttribute("BuyTime")), new SqlParameter("@Status",lEm.GetAttribute("Status")), new SqlParameter("@Deploy",lEm.GetAttribute("Deploy")), new SqlParameter("@AdminCD",lEm.GetAttribute("AdminCD")), new SqlParameter("@AdminNM",lEm.GetAttribute("AdminNM")), new SqlParameter("@Guid",System.Guid.NewGuid().ToString()), new SqlParameter("@Modify",lEm.GetAttribute("Modify")), new SqlParameter("@ModifyNM",lEm.GetAttribute("ModifyNM")), new SqlParameter("@NewTime",DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), new SqlParameter("@UserNo",lEm.GetAttribute("UserNo")), new SqlParameter("@UserNM",lEm.GetAttribute("UserNM")) }; sqlhelper.ExecuteNonQuery(sqlcommand, CommandType.Text, SqlStr, paras); } //sqlhelper.TranSqlCommadCommit(sqlcommand); sqlhelper.TranSqlCommadCommit(sqlcommand,sqlhelper.SqlTransaction); return "ok|保存成功!"; } catch (Exception ex) { //sqlhelper.TranSqlCommadRollback(sqlcommand);//出现SqlCommand.Transaction会变成null 的现象。 sqlhelper.TranSqlCommadRollback(sqlcommand, sqlhelper.SqlTransaction);//出现 此 SqlTransaction 已完成;它再也无法使用 return "er|" + ex.Message; } }问题:1.在执行SqlStr = "INSERT INTO [SP_Revise]([Code],[CType]....语句时候出现异常后进行回滚,可是却出现SqlCommand.Transaction会变成null 的现象。问题:2.是否不用指明Rollback(),如果有异常的话,事物会自动回滚?