I have a simple console application written using Delphi XE2.
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.
When I run this, I get this error:
'DBX error: The driver cannot be correctly initialized. The client library may be missing, not installed properly, the wrong version, or the driver may be missing on the system path. ''
If I add a VCL form to the application, I get a pop-up window about including the "Visual Component Library" frame, which I say No , and without doing anything else, now when I launch the application, I get "myConnection Is connected".
The only difference I see is in the uses clause:
uses
System.SysUtils,
Data.DBXMSSQL,
Data.DB,
Data.SqlExpr,
Unit1 in 'Unit1.pas' {Form1}
Unit1 'Unit1.pas' {Form1} uses, .
, , , ?