【问题标题】:Delphi 2007 DBX Access Violation in dbxmys30.dlldbxmys30.dll 中的 Delphi 2007 DBX 访问冲突
【发布时间】:2011-05-28 12:25:06
【问题描述】:

我正在尝试使用 Delphi 2007 中的 dbexpress 组件连接到 MySQL 数据库,但收到错误消息“模块 'dbxmys30.dll' 中地址 0B86E258 的访问冲突。读取地址 00000000”。

我有一个 TSQLConnection 使用 MySQL 驱动程序和设置来连接到 MySQL 5.1 数据库。我可以毫无问题地将其设置为活动状态。

当我尝试使用任意数量的组件从数据库中获取数据时,就会出现问题。更具体地说,我有一个 TSQLTable 对象。我将 SQLConnection 参数设置为我创建的 TSQLConnection,并将表名设置为我数据库中的一个表。当我尝试将 Active 设置为 true 时,我得到了错误。这发生在设计模式以及运行时。任何其他尝试从数据库获取数据的 dbx 组件也会发生这种情况。

我正在运行带有 MySQL 5.1 客户端和服务器的 Windows 7 64 位。我可以使用 MySQL 查询浏览器在数据库上运行查询,没有任何问题。

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: delphi delphi-2007


    【解决方案1】:

    您的版本不兼容,您使用的“libmysql.dll”版本与构建 dbx 驱动程序的版本不兼容。 embarcadero 论坛上的This thread 建议使用版本“5.0.27”,this thread 建议使用“5.0.24”。我成功的最新版本是'5.1.11'。

    顺便说一句,因为 'libmysql.dll' 不包含版本信息,我受够了跟踪哪个 dll 是哪个版本,我不得不写这个小东西:

    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;
    

    【讨论】:

    • 准确地说 - v 5.0.6 及更高版本,因为在 5.0.6 中对 MySQL API 结构进行了重大更改。
    【解决方案2】:

    Access Violation ... read of address 00000000 表示有东西试图取消引用 nil 指针。你有 dbxmys30.dll 的源代码吗?如果是这样,这将非常容易调试。如果没有,除了提交错误报告(谁创建了 dbxmys30.dll,顺便说一句?)并希望它尽快得到修复之外,您无能为力。

    【讨论】:

    • 那是 dbExpress v3 MySQL 驱动程序。
    • @David:那么它来自 Embarcadero?在这种情况下,Eric 需要在 QC 中提交错误报告。
    • 它可以追溯到 Borland/CodeGear 时代。它是旧的 D2006/2007。错误报告不太可能产生太大影响。 QC 中的错误报告没有太大影响,即使它们引用当前版本中的阻碍,moan moan moan!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-12
    • 2010-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多