title: Why Does Delphi Console Application Need Form For TSQLConnection To Work?
body: <p>I have a simple Console Application written using Delphi XE2.</p>
  
  <pre><code>program Project1;
  
  {$APPTYPE CONSOLE}
  
  {$R *.res}
  
  uses
    System.SysUtils,
    Data.DBXMSSQL,
    Data.DB,
    Data.SqlExpr;
  
  var
    myConnection: TSQLConnection;
  
  begin
    try
      { TODO -oUser -cConsole Main : Insert code here }
  
      myConnection := TSQLConnection.Create(nil);
      myConnection.DriverName := 'MSSQL';
      myConnection.GetDriverFunc := 'getSQLDriverMSSQL';
      myConnection.LibraryName := 'dbxmss.dll';
      myConnection.VendorLib := 'sqlncli10.dll';
      myConnection.LoginPrompt := False;
      myConnection.Params.Clear;
      myConnection.Params.Add('drivername=MSSQL');
      myConnection.Params.Add('schemaoverride=%.dbo');
      myConnection.Params.Add('hostname=myserver');
      myConnection.Params.Add('database=mydb');
      myConnection.Params.Add('blobsize=1');
      myConnection.Params.Add('localcode=0000');
      myConnection.Params.Add('isolationlevel=ReadCommited');
      myConnection.Params.Add('os authentication=True');
      myConnection.Params.Add('prepare sql=False');
      myConnection.Connected := true;
  
      Writeln('myConnection Is connected');
    except
      on E: Exception do
        Writeln(E.ClassName, ': ', E.Message);
    end;
  
    Readln;
  end.
  </code></pre>
  
  <p>When I run this, I get this error:</p>
  
  <blockquote>
    <p>'DBX Error:  Driver could not be properly initialized.  Client library
    may be missing, not installed properly, of the wrong version, or the
    driver may be missing from the system path.'</p>
  </blockquote>
  
  <p>If I add a VCL form to the application, I get the pop-up about enabling the "Visual Component Library" framework, which I say <strong>No</strong> to, and without doing anything else, now when I run the application I get 'myConnection Is connected'.</p>
  
  <p>The only difference I can see is in the uses clause:</p>
  
  <pre><code>uses
    System.SysUtils,
    Data.DBXMSSQL,
    Data.DB,
    Data.SqlExpr,
    Unit1 in 'Unit1.pas' {Form1}
  </code></pre>
  
  <p>If I remove the <em>Unit1 in 'Unit1.pas' {Form1}</em> from the uses clause then the app fails to connect.</p>
  
  <p>I do not want to include a form in my console application, so what is happening to the program when I do such that it works? </p>