title: dbexpress and SQL Server
body: <p>Delphi XE Tokio / SQL Server 2017 Express </p>
  
  <p>I am trying to connect an application developed in Delphi with a SQL Server database, before we did it with ADO and it worked very well, but now our client requests to use dbExpress.</p>
  
  <p>When trying to make the connection I get the famous error: </p>
  
  <blockquote>
    <p>DBX Error: Driver could not be initialized.</p>
  </blockquote>
  
  <p>Client library may be missing, not installed properly, of the wrong version, or the driver may be missing from the system path ... </p>
  
  <p>I have already tried to solve the solutions I found on this topic.</p>
  
  <ol>
  <li>Check the library</li>
  <li>copy it system32</li>
  <li>copy it SysWow.</li>
  <li>Copy it to the directory of the .exe</li>
  <li>Start the CoInitilized of ActiveEx</li>
  <li>Uninstall the sql server express</li>
  <li>Use the devart component.</li>
  <li>Register the library (regsvr32 sqlncli11.dll).</li>
  <li>Obviously install the native client, SQL Server!</li>
  </ol>
  
  <p>Absolutely no option has worked for me, it keeps getting the error in the instruction (<code>SQLConnection.Connected: = true;</code>).</p>
  
  <p>I have read this and it does not work either.
  <a href="https://stackoverflow.com/questions/31443220/delphi-dbx-and-mysql-connection-nightmare-dbx-error-driver-could-not-be-prope">Delphi DBX and MySQL connection nightmare : DBX Error: Driver could not be properly initialized</a></p>
  
  <pre><code>if CoInitialize(Nil) &gt; 0 then begin
    SQLConnection := TSQLConnection.Create(nil);
    SQLConnection.DriverName := 'MSSQL';
    SQLConnection.GetDriverFunc := 'getSQLDriverSQLServer';
    SQLConnection.LibraryName := 'dbxmss.dll';
    SQLConnection.VendorLib := 'sqlncli11.dll';
    SQLConnection.LoginPrompt := False;
    SQLConnection.Params.Clear;
    SQLConnection.Params.Add('drivername=MSSQL');
    SQLConnection.Params.Add('schemaoverride=%.dbo');
    SQLConnection.Params.Add('hostname=SQLEXPRESS');
    SQLConnection.Params.Add('database=LogSwitch');
    SQLConnection.Params.Add('blobsize=1');
    SQLConnection.Params.Add('localcode=0000');
    SQLConnection.Params.Add('isolationlevel=ReadCommited');
    SQLConnection.Params.Add('os authentication=True');
    SQLConnection.Params.Add('prepare sql=False');
    SQLConnection.Connected := true;
  end;
  </code></pre>