示例#1
0
        public int ModifyPwd(SysAdmin objAdmin)
        {
            //组合SQL语句
            string sql = "update Admins set LoginPwd='{0}' where LoginId={1}";

            sql = string.Format(sql, objAdmin.LoginPwd, objAdmin.LoginId);

            try
            {
                return(SQLHelper.Update(sql));
            }
            catch (SqlException)
            {
                throw new Exception("应用程序和数据库连接出现问题!");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public int DeleteStudentById(string studentId)
        {
            string sql = "delete from Students where StudentId=" + studentId;

            try
            {
                return(SQLHelper.Update(sql));
            }
            catch (SqlException ex)
            {
                if (ex.Number == 547)
                {
                    throw new Exception("this student object exists in other tables, can't delete it!");
                }
                else
                {
                    throw new Exception("Data base exception! information is: " + ex.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }