0

I have established this connection with my database but when I start the program it just hangs:

    System.Data.SqlClient.SqlConnection con;

    private void window_loaded(object sender, RoutedEventArgs e)
    {
        con = new System.Data.SqlClient.SqlConnection();
        con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Trial01.mdf;Connect Timeout=30;User Instance=True";
        con.Open();
        MessageBox.Show("Connection opened");
        con.Close();
        MessageBox.Show("Connection closed");
    }
J.Do
  • 303
  • 6
  • 26
  • Possible duplicate of [How do I connect to an MDF database file?](https://stackoverflow.com/questions/8926512/how-do-i-connect-to-an-mdf-database-file) – grek40 Sep 26 '17 at 08:28
  • On which statement exactly does it "hang"? – grek40 Sep 26 '17 at 12:15

0 Answers0