[FireDac] [物理学] [MySQL的] -11011。不支持的MySQL版本[0]。 Firemonkey delphi和firedac

时间:2013-09-03 03:53:06

标签: mysql delphi dll firedac firemonkey-fm3

你好我有点问题。我已经成功创建了一个从dll部署的表单。所以我自言自语为什么不尝试在DLL中添加数据库连接。我去阅读DLL http://docs.embarcadero.com/products/rad_studio/firedac/DLL_Development.html的文档尝试了演示,它工作,所以我将演示转换为mysql演示,看看它是否可行。当我尝试使用主应用程序表单Project1.exe调用Dll时,它显示此错误

[FireDac] [物理学] [MySQL的] -11011。不支持的MySQL版本[0]。支持从v 3.20到v6.2的客户端和服务器。

但有趣的是我使用相同的库,我用来将主应用程序连接到使用相同组件的mysql服务器。基本上,应用程序与dll表单共享一个连接,我认为理论上它可以工作。请帮我解决这个问题,下面是代码。如果我做错了,请告诉我。

主要应用程序 - Project1.exe

   unit ManageSystem;

interface

uses
  System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMX.StdCtrls, FMX.TabControl, FMX.Menus, FMX.Layouts, FMX.ListBox, FMX.Edit, SettingsFrm,
  ChangePass, FMX.Objects, GroupsNPerm, AddUser,
  {$IFDEF MSWINDOWS}
  Winapi.Windows,
  {$ENDIF}
  System.SysUtils;

type

  TShowDataProc = procedure (ACliHandle: Pointer); stdcall;
  TManageF = class(TForm)
    TabControl1: TTabControl;
    TabItem1: TTabItem;
    TabItem2: TTabItem;
    StyleBook2: TStyleBook;
    ListboxPopupMenu1: TPopupMenu;
    MenuItem1: TMenuItem;
    MenuItem2: TMenuItem;
    MenuBar1: TMenuBar;
    MenuItem3: TMenuItem;
    MenuItem4: TMenuItem;
    Panel1: TPanel;
    AddUsreBtn: TButton;
    GroupBox1: TGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    FirstNameEdit: TEdit;
    Label5: TLabel;
    LastNameEdit: TEdit;
    Label6: TLabel;
    EmailEdit: TEdit;
    Label7: TLabel;
    AddressEdit: TEdit;
    Label8: TLabel;
    TeleEdit: TEdit;
    Label9: TLabel;
    CellEdit: TEdit;
    Label10: TLabel;
    CommentEdit: TEdit;
    EditBtn: TButton;
    ChangePassBtn: TButton;
    DeleteAcBtn: TButton;
    SaveBtn: TButton;
    CancelBtn: TButton;
    UserNameEdit: TEdit;
    GroupsBtn: TButton;
    Label1: TLabel;
    Label2: TLabel;
    UserListBox: TListBox;
    UserSearchEdit: TEdit;
    SearchEditButton1: TSearchEditButton;
    procedure GroupsBtnClick(Sender: TObject);



  private
  FhDll: THandle;
  FpShowData: TShowDataProc;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ManageF: TManageF;

implementation

{$R *.fmx}

uses
  uADStanUtil;



procedure TManageF.GroupsBtnClick(Sender: TObject);
var
permissions : string;
begin

  {$IFDEF WIN32}
  {Permissions library to restrict access for unauthorized users}
  permissions := 'permsec.dll';

  {$ENDIF}

  {$IFDEF WIN64}
  permissions := 'permsec.dll';
  {$ENDIF}

  {$IFDEF MACOS}
  {Permissions library to restrict access for unauthorized users}
  permissions := '/usr/lib/libpermsec.dylib';
  {$ENDIF}
  FhDll := LoadLibrary(PChar(permissions));
  if FhDll = 0 then
    raise Exception.Create(ADLastSystemErrorMsg);
  @FpShowData := GetProcAddress(FhDll, PChar('ShowGroupsNPerm'));
  if not Assigned(FpShowData) then
    raise Exception.Create(ADLastSystemErrorMsg);
  FpShowData(SettingsF.ADConnection1.CliHandle);
end;

Dll库Project2.dll

   library permsec;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  System.SysUtils,
  System.Classes,
  uADCompClient,
  uADStanFactory,
  GroupsNPerm in 'GroupsNPerm.pas' {GroupsF};


procedure ShowGroupsNPerm(ACliHandle: Pointer); stdcall;
begin
TGroupsF.ShowGroupsNPerm(ACliHandle);
end;

{$R *.res}
exports
  ShowGroupsNPerm;

begin
end.

GroupsNPerm.pas是dll中的表单

unit GroupsNPerm;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMX.StdCtrls, FMX.Layouts, FMX.ListBox, FMX.TreeView, uADStanIntf,
  uADStanOption, uADStanParam, uADStanError, uADDatSManager, uADPhysIntf,
  uADDAptIntf, uADStanAsync, uADDAptManager, Data.DB, uADCompDataSet,
  uADCompClient, uADGUIxIntf, uADPhysManager, uADPhysMySQL,
  uADCompGUIx, uADGUIxFMXWait, uADStanDef, uADStanPool;

type
  TGroupsF = class(TForm)
    ToolBar1: TToolBar;
    CreateGpBtn: TButton;
    EditGrpBtn: TButton;
    DeleGpBtn: TButton;
    GrpListBox1: TListBox;
    Panel1: TPanel;
    TreeView1: TTreeView;
    TreeViewItem1: TTreeViewItem;
    TreeViewItem2: TTreeViewItem;
    TreeViewItem3: TTreeViewItem;
    TreeViewItem4: TTreeViewItem;
    TreeViewItem5: TTreeViewItem;
    TreeViewItem6: TTreeViewItem;
    TreeViewItem7: TTreeViewItem;
    TreeViewItem8: TTreeViewItem;
    TreeViewItem9: TTreeViewItem;
    TreeViewItem10: TTreeViewItem;
    TreeViewItem11: TTreeViewItem;
    ADQuery1: TADQuery;
    ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
    ADGUIxWaitCursor1: TADGUIxWaitCursor;
    ADPermConnect: TADConnection;
    procedure GrpListBox1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);



  private
    { Private declarations }
  public
    { Public declarations }
     class procedure ShowGroupsNPerm(ACliHandle: Pointer);
  end;

var
  GroupsF: TGroupsF;

implementation

{$R *.fmx}



class procedure TGroupsF.ShowGroupsNPerm(ACliHandle: Pointer);
var
  oForm: TGroupsF;
begin

  oForm := TGroupsF.Create(nil);
  oForm.ADPermConnect.SharedCliHandle := ACliHandle;
  oForm.ADPermConnect.Connected := True;
  oForm.ADQuery1.Close;
  oForm.ADQuery1.SQL.Clear;
  oForm.ADQuery1.SQL.Text := 'SELECT Group_Name FROM groups ORDER BY Group_Name';
  try
  oForm.ADQuery1.Open;
  oForm.GrpListBox1.Items.Clear;
  while not oForm.ADQuery1.Eof do
  begin
    oForm.GrpListBox1.Items.Add(oForm.ADQuery1.Fields[0].AsString);
    oForm.ADQuery1.Next;
  end;
  finally
  oForm.ADQuery1.Close;
  end;
  //oForm.ADQuery1.Active := True;
  oForm.ShowModal;
  oForm.Free;
end;





procedure TGroupsF.FormCreate(Sender: TObject);
begin
{$IFDEF WIN32}
ADPhysMySQLDriverLink1.VendorLib := ExtractFilePath(ParamStr(0)) + '/libmysqlx86.dll' ;
{$ENDIF}

{$IFDEF WIN64}
ADPhysMySQLDriverLink1.VendorLib := ExtractFilePath(ParamStr(0)) + '/libmysqlx64.dll'  ;
{$ENDIF}

{$IFDEF MACOS}
ADPhysMySQLDriverLink1.VendorLib := '/usr/lib/libmysqlclient.dylib';
{$ENDIF}
end;

procedure TGroupsF.GrpListBox1Click(Sender: TObject);

begin
ADQuery1.Close;
ADQuery1.SQL.Clear;
ADQuery1.SQL.Text := 'SELECT * FROM groups WHERE Group_Name = :group';
ADQuery1.ParamByName('group').AsString := GrpListBox1.Items.Strings[GrpListBox1.ItemIndex];
ADQuery1.Open;

if ADQuery1.FieldByName('Access_Management_System').AsBoolean = TRUE   then
TreeViewItem1.Ischecked := True
else
TreeViewItem1.Ischecked := False  ;

if ADQuery1.FieldByName('Access_Pos').AsBoolean = TRUE   then
TreeViewItem6.Ischecked := True
else
TreeViewItem6.Ischecked := False

end;

end.

0 个答案:

没有答案