Tho calling module also:unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, DBAccess, MSAccess, Vcl.Grids,
Vcl.DBGrids;
type
TForm3 = class(TForm)
DBGrid1: TDBGrid;
MSDataSource1: TMSDataSource;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure ShowIt(DS:TDataset);
end;
var
Form3: TForm3;
procedure ShowForm(DS:TDataset);
exports
ShowForm;
implementation
{$R *.dfm}
procedure TForm3.ShowIt(DS:TDataset);
begin
MSDataSource1.DataSet:=DS;
ShowModal;
end;
procedure ShowForm(DS:TDataset);
Begin
Form3:=TForm3.Create(nil);
try
Form3.ShowIt(DS);
finally
FreeAndNil(Form3);
end;
End;
end.
After Closing the EAccessViolation Error is dropped if the MSTable is assigned to the MSDatasource. If it isn't, there is no error. Even changing ShowIt-proc tounit Unit4;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB, MemDS, DBAccess,
MSAccess;
type
TForm4 = class(TForm)
Button1: TButton;
MSConnection1: TMSConnection;
MSTable1: TMSTable;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
TDSProc = procedure(DS:TDataset);
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
var h:THandle;
p:TDSProc;
begin
H:= LoadPackage('D:\TEMP\20180923 -- BPL-Test\Package1250.bpl');
try
if (H <> 0) then
begin
@P := GetProcAddress(H, 'ShowForm');
if Assigned(P) then
P(MSTable1);
end;
finally
UnloadPackage(H);
end;
end;
procedure TForm4.Button2Click(Sender: TObject);
begin
MSTable1.Active:=False;
MSTable1.Connection:=nil;
MSConnection1.Connected:=False;
Close;
end;
end.
Does not change this behaviour.procedure TForm3.ShowIt(DS:TDataset);
begin
MSDataSource1.DataSet:=DS;
ShowModal;
MSDataSource1.DataSet:=nil;
end;
Please give me a short note how to prevent the EAccessError.