public void OpenDatabase(){try{sqlcon.Open();}catch (SqlException ex){throw new Exception("Problem opening database");}catch (Exception ex){MessageBox.Show(ex.Message);}}static SqlConnection sqlcon; public void Main1(){sqlcon = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\NewFPDB.mdf;Integrated Security=SSPI;User ID=FPDB_Admin;Password=123456;Persist Security Info=True;Connect Timeout=30;User Instance=False;");SqlCommand command = new SqlCommand("SELECT AirportID from Airports", sqlcon);OpenDatabase();// Get the data readerSqlDataReader reader = command.ExecuteReader();// Process each resultreader.Read(); if (reader != null){MessageBox.Show("1");Application.Run(new Form1());sqlcon.Close();}else{Application.Run(new Form2());sqlcon.Close();} reader.Close();sqlcon.Close();} [STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);sqlcon = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\NewFPDB.mdf;Integrated Security=SSPI;User ID=FPDB_Admin;Password=123456;Persist Security Info=True;Connect Timeout=30;User Instance=False;");sqlcon.Open();SqlCommand command = new SqlCommand("SELECT UserID from Users", sqlcon);// Get the data readerSqlDataReader reader = command.ExecuteReader();// Process each resultreader.Read(); if (reader != null){//MessageBox.Show("1");Application.Run(new Form1());sqlcon.Close();}else{Application.Run(new Form2());sqlcon.Close();} // Close the reader and the connectionreader.Close();sqlcon.Close(); }