Delphi 2007 DBX Access Violation in dbxmys30.dll
I'm trying to use the dbexpress components in Delphi 2007 to connect to a MySQL database but getting an error the reads "Access violation at address 0B86E258 in module 'dbxmys30.dll'. Read of address 00000000".
I have a TSQLConnection using the MySQL drivers and setup to connect to a MySQL 5.1 database. I can set it to active without a problem.
The problem arises when I try to get data from the database using any number of components. To be more specific, I have a TSQLTable object. I set the SQLConnection parameter开发者_开发知识库 to the TSQLConnection I created and set table name to a table in my database. When I try to set Active to true I get the error. This happens in design mode as well as at runtime. It will also happen with any other dbx component that try to get data from the database.
I'm running Windows 7 64 bit with a MySQL 5.1 client and server. I can run queries on the database using MySQL Query Browser without any issues.
Any Help would be much appreciated. Thanks!
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;
Access Violation ... read of address 00000000
means that something is trying to dereference a nil pointer. Do you have the source to dbxmys30.dll? If so, this will be very easy to debug. If not, there's not much you can do except file a bug report (who created dbxmys30.dll, BTW?) and hope it gets fixed quickly.
精彩评论