Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Checks the password for the given user name
- /// </summary>
- /// <param name="uName">The username which we we want password of</param>
- /// <returns>The password of the given user name</returns>
- public string GetPassword(string uName)
- {
- OleDbCommand cmd = new OleDbCommand("GetPassword", _connection);
- cmd.CommandType = CommandType.StoredProcedure;
- OleDbParameter param;
- param = cmd.Parameters.Add("input", OleDbType.BSTR);
- param.Direction = ParameterDirection.Input;
- param.Value = uName;
- try
- {
- _connection.Open();
- return cmd.ExecuteScalar().ToString();
- }
- catch(Exception ex)
- {
- throw ex;
- }
- finally
- {
- _connection.Close();
- }
- }
- /// <summary>
- /// The function adds new user to the user's table in the database
- /// </summary>
- /// <param name="uName">The new user's name</param>
- /// <param name="uPass">The new user's password</param>
- /// <param name="uMail">The new user's email</param>
- public void AddUser(string uName, string uPass, string uMail)
- {
- OleDbCommand cmd = new OleDbCommand("AddUser", _connection);
- cmd.CommandType = CommandType.StoredProcedure;
- OleDbParameter param;
- param = cmd.Parameters.Add("userName", OleDbType.BSTR);
- param.Direction = ParameterDirection.Input;
- param.Value = uName;
- param = cmd.Parameters.Add("userPass", OleDbType.BSTR);
- param.Direction = ParameterDirection.Input;
- param.Value = uPass;
- param = cmd.Parameters.Add("userMail", OleDbType.BSTR);
- param.Direction = ParameterDirection.Input;
- param.Value = uMail;
- try
- {
- _connection.Open();
- if (cmd.ExecuteNonQuery() == 0)
- throw new Exception("User was not added to the database");
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- _connection.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement