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(); }
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); }
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); }
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()); }
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); }
/// <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); }