You have a version incompatibility, the version of 'libmysql.dll' you're using is incompatible with the version that the dbx driver is built against. This thread on embarcadero forums suggests to use version '5.0.27' and this thread suggests '5.0.24'. The latest version I had success was '5.1.11'.
BTW, because 'libmysql.dll' contains no version info, I was fed up with keeping track of which dll was which version and I had to wrote this little thing:
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FLastFile: string;
procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
shellapi;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
DragAcceptFiles(Handle, True);
Width := 350;
Height := 110;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DragAcceptFiles(Handle, False);
end;
procedure TForm1.FormPaint(Sender: TObject);
var
R: TRect;
begin
Canvas.TextOut(40, 16, 'Drop libmysql.dll to find out version');
R := Rect(14, 40, ClientWidth, ClientHeight);
DrawText(Canvas.Handle, PChar(FLastFile), Length(FLastFile), R, DT_LEFT);
end;
function GetVersion(ClientDll: PChar): UINT;
const
FUNC = 'mysql_get_client_version';
FUNCTIONNOTFOUND = '%s: ''%s'' in ''%s''.';
UNABLETOLOADLIB = 'Unable to load library (''%s''): ''%s''.';
var
LibHandle: HMODULE;
GetClientVersionFunc: function: Integer;
begin
Result := 0;
LibHandle := LoadLibrary(ClientDll);
if LibHandle <> 0 then begin
try
@GetClientVersionFunc := GetProcAddress(LibHandle, FUNC);
if @GetClientVersionFunc <> nil then begin
Result := GetClientVersionFunc;
end else
raise EOSError.CreateFmt(FUNCTIONNOTFOUND,
[SysErrorMessage(GetLastError), FUNC, ClientDll]);
finally
FreeLibrary(LibHandle);
end;
end else
raise EOSError.CreateFmt(UNABLETOLOADLIB, [ClientDll,
SysErrorMessage(GetLastError)]);
end;
procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
var
len: Integer;
DropName: string;
Ver: UINT;
begin
len := DragQueryFile(Msg.Drop, 0, nil, 0) + 1;
SetLength(DropName, len);
len := DragQueryFile(Msg.Drop, 0, PChar(DropName), len);
SetLength(DropName, len);
try
try
Ver := GetVersion(PChar(DropName));
except
FLastFile := '';
raise;
end;
if Boolean(Ver) then
FLastFile := DropName + #10 +'[' + IntToStr(Ver) + '] - ' +
IntToStr(Ver div 10000) + '.' + IntToStr((Ver div 100) mod 100)
+ '.' + IntToStr(Ver mod 100)
else
FLastFile := '';
finally
Invalidate;
DragFinish(Msg.Drop);
Msg.Result := 0;
end;
end;