title: SqlConnection from class into SqlCommand
body: <p>Hello I have got this code in class which runs SqlConnection:</p>
  
  <pre><code>using System.Data.SqlClient;
  using System.IO;
  
  namespace tours
  {
      class myConnection
      {
          public static SqlConnection GetConnection()
          {
                  string path = "C:\\Users\\marek\\Documents\\Visual Studio 2012\\Projects\\tours\\tours\\sql_string.txt";
                  StreamReader sr = new StreamReader(File.Open(path, FileMode.Open));
  
                  string str = "Data Source='" + sr.ReadLine() + "';Initial Catalog ='" + sr.ReadLine() + "' ;User ='" + sr.ReadLine() + "';Password = '" + sr.ReadLine() + "'";
  
                  SqlConnection spojeni = new SqlConnection(str);
                  spojeni.Open();
                  return spojeni;
          }
      }
  }
  </code></pre>
  
  <p>In other forms I got <code>SqlCommand</code> or <code>SqlDataAdapter</code> and I need to add to them <code>SqlConnection</code>, but don't know how can I access them? Would you please suggest me something? for example this: </p>
  
  <pre><code>DataTable dt = new DataTable();
  SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM zajezd",);
  SDA.Fill(dt);
  </code></pre>