Ejemplo n.º 1
0
        /// <summary>
        /// set new user in the DB.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="role"></param>
        public void setNewUser(string userName, string password, Role role)
        {
            userName = userName.ToLower();
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    cmd        = new SqlCommand("INSERT INTO Users(UserName, Password, Role) VALUES('" + userName + "','" + password + "','" + role.ToString() + "')", connection);

            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
                connection.Close();
            }
            catch
            {
                throw new Exception("connection faild");
            }
        }