[FireDac][Phys][MySQL]-11011. Unsupported MySQL version [0] Delphi
Hello im having a bit of a problem. I have successfully created a form to
be deployed from a dll. So i said to my self why not try to add database
connectivity within the DLL. I went and read the documentation for DLL
http://docs.embarcadero.com/products/rad_studio/firedac/DLL_Development.html
tried the demo and it worked so i converted the demo to a mysql demo to
see if it would work. When i try calling the Dll with the main application
form Project1.exe it showed this error
[FireDac][Phys][MySQL]-11011. Unsupported MySQL version [0]. Supported are
client and server from v 3.20 to v6.2.
But the funny thing is im using the same librarys i used to connect the
Main Application to my mysql server which uses the same components.
Basically the Application shares a connection with the dll form in which i
thought in theory it would work. Please Help me solve this here is the
code below. Please tell me if im doing anything wrong.
Main Application- Project1.exe
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
uADDatSManager, uADStanParam, uADDAptIntf, StdCtrls, Grids, DBGrids,
DB, uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx,
uADCompDataSet,
uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
uADDAptManager, uADPhysODBCBase, uADGUIxFMXWait, uADPhysMySQL;
type
TShowDataProc = procedure (ACliHandle: Pointer); stdcall;
TShutdownProc = procedure; stdcall;
TForm1 = class(TForm)
ADConnection1: TADConnection;
ADQuery1: TADQuery;
ADGUIxWaitCursor1: TADGUIxWaitCursor;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
FhDll: THandle;
FpShowData: TShowDataProc;
FpShutdown: TShutdownProc;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
uADStanUtil;
procedure TForm1.Button1Click(Sender: TObject);
begin
FhDll := LoadLibrary(PChar('Project2.dll'));
if FhDll = 0 then
raise Exception.Create(ADLastSystemErrorMsg);
@FpShowData := GetProcAddress(FhDll, PChar('ShowData'));
if not Assigned(FpShowData) then
raise Exception.Create(ADLastSystemErrorMsg);
@FpShutdown := GetProcAddress(FhDll, PChar('Shutdown'));
if not Assigned(FpShutdown) then
raise Exception.Create(ADLastSystemErrorMsg);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
FpShowData(ADConnection1.CliHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
FpShutdown();
FreeLibrary(FhDll);
FhDll := 0;
@FpShowData := nil;
@FpShutdown := nil;
end;
end.
Dll library Project2.dll
library Project2;
{ 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
SysUtils,
Classes,
Forms,
uADCompClient,
uADStanFactory,
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
procedure ShowData(ACliHandle: Pointer); stdcall;
begin
TForm2.ShowData(ACliHandle);
end;
procedure Shutdown; stdcall;
var
i: Integer;
begin
for i := Application.ComponentCount - 1 downto 0 do
if Application.Components[i] is TForm then
Application.Components[i].Free;
ADTerminate;
end;
exports
ShowData,
Shutdown;
begin
end.
Unit2- The form in the Dll
This has a query that does a simple select all from the suppliers database
in the firedac demo datbase
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
uADDatSManager, uADStanParam, uADDAptIntf, Grids, DBGrids, DB,
uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx,
uADCompDataSet,
uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
uADDAptManager, uADPhysODBCBase, uADGUIxFMXWait, uADPhysMySQL;
type
TForm2 = class(TForm)
ADConnection1: TADConnection;
ADQuery1: TADQuery;
ADGUIxWaitCursor1: TADGUIxWaitCursor;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADPhysMySQLDriverLink1: TADPhysMySQLDriverLink;
public
class procedure ShowData(ACliHandle: Pointer);
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TForm2 }
class procedure TForm2.ShowData(ACliHandle: Pointer);
var
oForm: TForm2;
begin
oForm := TForm2.Create(Application);
oForm.ADConnection1.SharedCliHandle := ACliHandle;
oForm.ADConnection1.Connected := True;
oForm.ADQuery1.Active := True;
oForm.Show;
end;
end.
No comments:
Post a Comment