与MDF本地数据库的连接挂起

时间:2017-09-26 08:02:13

标签: c# wpf database

我已经与我的数据库建立了此连接,但是当我启动该程序时,它只是挂起:

    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");
    }

0 个答案:

没有答案