//工程分开后,命名空间就可以区分开来了 public SqlDbHelper() { ConnectionStringSettings set = ConfigurationManager.ConnectionStrings["SqlConnection"];//连接sqlserver的字符串 if (set == null) { throw new ConfigurationErrorsException("配置文件key有误。应该为:ConnString"); } string strSql = set.ConnectionString; Conn = new SqlConnection(strSql);//连接数据库 TransactionState = ETransactionState.Commit; }
/// <summary> /// 开始事务 /// </summary> /// <param name="tranState">事务状态</param> public void BeginTran(ETransactionState tranState) { this.TransactionState = tranState; this.BeginTran(); }
/// <summary> /// 提交事务 /// </summary> /// <param name="tranState">事务状态</param> /// <returns>执行成功返回true,否则false</returns> public bool CommitTran(ETransactionState tranState) { this.TransactionState = tranState; return(this.CommitTran()); }