title: What's the difference between using statement and adding a reference?
body: <p>In Visual Studio, when do you have to add a reference to a dll? I always try to have a minimum of references in my projects, I try to only include the ones that are really necessary.</p>
  
  <p>I would think that I only need a reference if I have a <code>using</code> statement in my source. But that's not always enough.</p>
  
  <p>For instance, I have a very simple program that is <code>using</code> System and Microsoft.Practices.EnterpriseLibrary.Data:</p>
  
  <pre><code>using System;
  using Microsoft.Practices.EnterpriseLibrary.Data;
  
  public class SimpleConnection {
      private static void Main() {
          var database = DatabaseFactory.CreateDatabase();
          var command =
              database.GetSqlStringCommand(
                  "select table_name from information_schema.tables");
          using (var reader = database.ExecuteReader(command)) {
              while (reader.Read()) {
                  Console.WriteLine(reader.GetString(0));
              }
          }
      }
  }
  </code></pre>
  
  <p>I would <em>think</em> I only have to reference System and Microsoft.Practices.EnterpriseLibrary.Data. But that's not true. If I don't reference System.Data, the code won't compile.</p>
  
  <blockquote>
    <p>The type
    'System.Data.Common.DbCommand' is
    defined in an assembly that is not
    referenced. You must add a reference
    to assembly 'System.Data,
    Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089'.</p>
  </blockquote>
  
  <p>How can I know beforehand when I have to add a reference to something I'm not <code>using</code>?</p>