예제 #1
0
        public static void RestoreDatabase(string path, string db)
        {
            string sql = string.Format("Restore database {0} from disk = '{1}'",
                                       db, path);

            ConnectionDB connectionDB = new ConnectionDB();

            connectionDB.OpenConnection();

            connectionDB.ExecuteNonQuery(CommandType.Text, sql);

            connectionDB.CloseConnection();
        }
예제 #2
0
        public static int ExcuteNonQuery(string sql)
        {
            ConnectionDB connectionDB = new ConnectionDB();

            connectionDB.OpenConnection();

            int nRow = 0;

            nRow = connectionDB.ExecuteNonQuery(CommandType.Text, sql);

            connectionDB.CloseConnection();

            return(nRow);
        }
예제 #3
0
        public static int InsertUpdateDelete(string sql)
        {
            ConnectionDB p = new ConnectionDB();

            p.OpenConnection();

            int nRow = 0;

            nRow = p.ExecuteNonQuery(CommandType.Text, sql);

            p.CloseConnection();

            return(nRow);
        }
예제 #4
0
        public static string GenerateMa(string tenSP)
        {
            string sql = tenSP;

            ConnectionDB connectionDB = new ConnectionDB();

            connectionDB.OpenConnection();

            SqlParameter ma = new SqlParameter("@kq", SqlDbType.VarChar, 10);

            ma.Direction = ParameterDirection.Output;

            connectionDB.ExecuteNonQuery(CommandType.StoredProcedure, sql, ma);

            connectionDB.CloseConnection();

            return(ma.Value.ToString());
        }
예제 #5
0
        public string GetPassword(string username)
        {
            string sql = "sp_GetPassword";

            ConnectionDB p = new ConnectionDB();

            p.OpenConnection();

            SqlParameter kq = new SqlParameter("@pass", SqlDbType.VarChar, 20);

            kq.Direction = ParameterDirection.Output;

            p.ExecuteNonQuery(CommandType.StoredProcedure, sql,
                              new SqlParameter {
                ParameterName = "@username", Value = username
            }, kq);

            string pass = kq.Value.ToString();

            return(pass);
        }
예제 #6
0
        /// <summary>
        /// lấy mã vai trò từ tên đăng nhập người dùng
        /// </summary>
        /// <param name="tendangnhap"></param>
        /// <returns></returns>
        public string LayMaVaiTro(string tendangnhap)
        {
            string sql = "sp_GetMaVaiTroND";

            ConnectionDB connectionDB = new ConnectionDB();

            connectionDB.OpenConnection();

            SqlParameter kq = new SqlParameter("@mavt", SqlDbType.VarChar, 10);

            kq.Direction = ParameterDirection.Output;

            connectionDB.ExecuteNonQuery(CommandType.StoredProcedure, sql,
                                         new SqlParameter {
                ParameterName = "@tendangnhap", Value = tendangnhap
            }, kq);

            string mavt = kq.Value.ToString();

            return(mavt);
        }