When i Run this code in a 32 bits delphi application the connection to MySql is successfully established.
{$APPTYPE CONSOLE}
{$R *.res}
uses
AdoDb,
ActiveX,
SysUtils;
Var
LConn : TADOConnection;
begin
try
CoInitialize(nil);
try
LConn:=TADOConnection.Create(nil);
try
LConn.ConnectionString:='Driver={MySQL ODBC 5.1 Driver};Server=127.0.0.1;Database=mysql;User=*****; Password=*****;Option=3';
LConn.Connected:=True;
Writeln('Connected');
finally
LConn.Free;
end;
finally
CoUninitialize;
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Readln;
end.
But the same code code fails with this exception
EOleException: [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified
If the code is compiled as a 64 bits application. the question is Why the same code fails in the 64 bits application?
To avoid this exception you must install the MySQL ODBC driver for 64 bits.