/// <summary> /// 尝试提交某个链接的事务,失败则回滚 /// </summary> /// <param name="key">要提交事务的链接的key</param> /// <returns></returns> public bool TryCommitTran(string key) { if (this.connectionList.ContainsKey(key)) { IDBHelper helper = this.connectionList[key]; if (helper.IsOnTransaction) { try { helper.CommitTran(); } catch (Exception ex) { string errDescribe = ex.Message + " 异常: " + ex.InnerException + "位置:" + ex.StackTrace + "对象名称:" + ex.Source + "引发异常的方法:" + ex.TargetSite; this.errorMessage += errDescribe; helper.RollbackTran(); return(false); } return(true); } return(true);//如果没有事务则返回成功 } return(false); }