我已经与我的数据库建立了此连接,但是当我启动该程序时,它只是挂起:
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");
}