Stargate SG1 - False Pretenses (Season 2 Ep. 4)
From The Episode "The Gamekeeper" Description From IMDB - Exploring a strange and beautiful garden, SG-1 comes across a dome containing a race that are connected to machines. The team are captured by the machines and rendered unconscious, but awake to find themselves reliving pivotal moments of their lives, over and over again. Then they discover it is virtual reality and a mysterious keeper appears to persuade them to try different outcomes for the moments. But can the team escape his clutches, when they don't know what is real and what is not?