/// <summary> /// /// </summary> /// <param name="databaseHelper"></param> /// <param name="user"></param> /// <param name="oldPassword"></param> /// <param name="newPassword"></param> public void NewPassword(DAODatabaseHelper databaseHelper, string user, string oldPassword, string newPassword) { this.BeginTransaction(); System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand(); TempCommand_2.CommandText = String.Format("ALTER LOGIN [{0}] WITH PASSWORD=N'{1}'", user, newPassword); TempCommand_2.CommandType = System.Data.CommandType.Text; TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection); DbCommand command = TempCommand_2; command.ExecuteNonQuery(); this.CommitTransaction(); }
/// <summary> /// Creates a new connection and opens it using the provided connection string. /// </summary> /// <param name="connectionString">The connection string with the information to connect to a database.</param> /// <returns>The newly created DBConnection object.</returns> protected DAODatabaseHelper Open(String connectionString) { DbConnection cn = factory.CreateConnection(); //cn.ConnectionString = connectionString + Credentials; //SQL cn.ConnectionString = connectionString; //Access cn.Open(); cn.StateChange += new System.Data.StateChangeEventHandler(result_StateChange); DAODatabaseHelper daodb = new DAODatabaseHelper(cn); connections.Add(daodb); return(daodb); }
/// <summary> /// /// </summary> /// <param name="databaseHelper"></param> /// <param name="OldGroup"></param> /// <param name="NewGroup"></param> /// <param name="user"></param> public void UpdateRole(DAODatabaseHelper databaseHelper, string OldGroup, string NewGroup, string user) { System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand(); TempCommand_2.CommandText = String.Format("exec sp_droprolemember '{0}', '{1}'", OldGroup, user); TempCommand_2.CommandType = System.Data.CommandType.Text; TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection); DbCommand command = TempCommand_2; command.ExecuteNonQuery(); TempCommand_2 = databaseHelper.CreateCommand(); TempCommand_2.CommandText = String.Format("exec sp_addrolemember '{0}', '{1}'", NewGroup, user); command = TempCommand_2; command.ExecuteNonQuery(); }
/// <summary> /// /// </summary> /// <param name="databaseHelper"></param> /// <param name="Username"></param> public void DeleteUser(DAODatabaseHelper databaseHelper, string Username) { System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand(); TempCommand_2.CommandText = String.Format("DROP USER {0}", Username); TempCommand_2.CommandType = System.Data.CommandType.Text; TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection); DbCommand command = TempCommand_2; command.ExecuteNonQuery(); TempCommand_2 = databaseHelper.CreateCommand(); TempCommand_2.CommandText = String.Format("DROP Login {0}", Username); command = TempCommand_2; command.ExecuteNonQuery(); }
/// <summary> /// /// </summary> /// <param name="databaseHelper"></param> /// <param name="Username"></param> /// <param name="Password"></param> /// <param name="UserRole"></param> public void CreateUser(DAODatabaseHelper databaseHelper, string Username, string Password, string UserRole) { this.BeginTransaction(); System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand(); TempCommand_2.CommandText = "sp_addnewuser"; TempCommand_2.CommandType = System.Data.CommandType.StoredProcedure; TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection); DbCommand command = TempCommand_2; ADORecordSetHelper.commandParameterBinding(command, "Username").Value = Username; ADORecordSetHelper.commandParameterBinding(command, "Password").Value = Password; ADORecordSetHelper.commandParameterBinding(command, "UserRole").Value = UserRole; command.ExecuteNonQuery(); this.CommitTransaction(); }
/// <summary> /// Rollbacks a transaction for a specific connection. /// </summary> /// <param name="connection">The connection to work on.</param> private void Rollback(DAODatabaseHelper connection) { TransactionManager.Rollback(connection.Connection); }
/// <summary> /// Commits a transaction for a specific connection. /// </summary> /// <param name="connection">The connection where the transaction will be committed.</param> private void CommitTransaction(DAODatabaseHelper connection) { TransactionManager.Commit(connection.Connection); }
/// <summary> /// Closes a transaction for a specific connection. /// </summary> /// <param name="connection">The connection where the transaction will be close.</param> private void Close(DAODatabaseHelper connection) { TransactionManager.DeEnlist(connection.Connection); connection.Close(); }
/// <summary> /// Begins a transaction for a specific connection. /// </summary> /// <param name="connection">The connection where the transaction will be initiated.</param> private void BeginTransaction(DAODatabaseHelper connection) { TransactionManager.Enlist(connection.Connection); }
/// <summary> /// Returns the Transaction object associated to a connection. /// </summary> /// <param name="dbh">The DAODatabaseHelper to get the transaction from.</param> /// <returns>The transaction associated with the parameter.</returns> public static DbTransaction GetTransaction(DAO.DAODatabaseHelper dbh) { return(GetTransaction(dbh.Connection)); }