Closing the MainWindow will kill the application, as it stores the main thread (main method), instead of this.Close();
use this.Hide();
and your code should work assuming your database connection is correct.
Anyway here is a very very quick example I wrote in WPF to help you understand passing parameters from one window to another correctly.