Defensive Database Programming - should I be using a Singleton pattern
<p>Is the following defensive programming?</p>

<p>What I mean is that if it loses the connection, or some problem occurs during run-time and then the user runsit again will the .NET framework have tidied up any open connections and objects that were created when it first ran?</p>

<p>I've heard mention of a "Singleton pattern" - is this something I should use in the static method CreateConnection?</p>

<pre><code>class Program {
  static void Main(string[] args) {
     DataTable CasTable = fillSampleDataTable("SELECT top 100 * FROM x");
     //do other stuff
  }


  static SqlConnection CreateConnection() {
     SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["XXX"].ConnectionString);
     return conn;
  }
  static SqlDataAdapter CreateAdapter(string myCommand) {
    SqlDataAdapter myAdapt = new SqlDataAdapter(myCommand, CreateConnection());
    return myAdapt;
  }
  static DataTable fillSampleDataTable(string myCommand) {
      using (var adapt = CreateAdapter(myCommand)) {                   
            DataSet mySet = new DataSet();
            adapt.Fill(mySet, "SampleData");
            return mySet.Tables["SampleData"];
    }
  }
 }
</code></pre>
