title: C# Can I Make an sqlConnection public and refer to it from other forms?
body: <p>I have an sqlConnection on my first form and wondered if I could make it public so I could refer to it from other forms. The code I have so far is below, but I don't know where I would make it public or how.</p>
  
  <pre><code>public partial class frmConnect : Form
  {
  
      public frmConnect()
      {
          InitializeComponent();
      }
  
      private void btnConnect_Click(object sender, EventArgs e)
      {
          String server;
  
          server = cmbConnect.SelectedItem.ToString();
  
          MessageBox.Show(server);
  
          sqlConnectionNW.ConnectionString = "Data Source=" + server + ";Initial Catalog=Northwind;Integrated Security=True";
  
          try
          {
              sqlConnectionNW.Open();
  
              MessageBox.Show("Successfully Connected!");
  
              frmSignIn frmLogIn = new frmSignIn();
  
              frmLogIn.server = server;
  
              sqlConnectionNW.Close();
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
  
          }
  
      }
  }
  </code></pre>
  
  <p>}</p>