有一个Udal的单元文件,主要是一个数据访问类,如:
TAccess = class
public
function ShowAllMan: TDataSource;
constructor create;
destrucotr Destory;
end;
//------在Ubll文件中实例化TAccess,如下:
Unit UBll;
.....
uses Udal;type
TBLL = class(TInterfaceObject, IBLL) //IBLL引出ShowAllMan方法的接口,在Ubll中
private
FAccess: TAccess;
function ShowAllMan: TDataSource;
public
constructor create;
destructor Destory;
end;
constructor TBLL.create;
begin
FAccess := TAccess.create; //这里出错
end;//-------以下是dll文件:
function BLL: IBLL;stdcall;
begin
result := TBLL.create;
end;
exports
BLL;//----以下是调用dll
uses Ibll,UBll;
.....
function BLL: IBLL;stdcall external 'DLLName.dll';
.....
procedure TForm1.Button1Click(Sender: TObject);
var
show: IBLL;
begin
show := BLL; //执行这句就出错,如果注释掉TBLL的构造函数的这行FAccess := TAccess.create;就无错.
DBGrid1.DataSource := show.ShowAllMan;
show := nil;
end;
麻烦各位出个注意,我是把对数据操作的业务层和数据访问层及DataModual封装到DLL中了,查询结构希望通过TDataSource返回,就象C#中的DataSet.
TAccess = class
public
function ShowAllMan: TDataSource;
constructor create;
destrucotr Destory;
end;
//------在Ubll文件中实例化TAccess,如下:
Unit UBll;
.....
uses Udal;type
TBLL = class(TInterfaceObject, IBLL) //IBLL引出ShowAllMan方法的接口,在Ubll中
private
FAccess: TAccess;
function ShowAllMan: TDataSource;
public
constructor create;
destructor Destory;
end;
constructor TBLL.create;
begin
FAccess := TAccess.create; //这里出错
end;//-------以下是dll文件:
function BLL: IBLL;stdcall;
begin
result := TBLL.create;
end;
exports
BLL;//----以下是调用dll
uses Ibll,UBll;
.....
function BLL: IBLL;stdcall external 'DLLName.dll';
.....
procedure TForm1.Button1Click(Sender: TObject);
var
show: IBLL;
begin
show := BLL; //执行这句就出错,如果注释掉TBLL的构造函数的这行FAccess := TAccess.create;就无错.
DBGrid1.DataSource := show.ShowAllMan;
show := nil;
end;
麻烦各位出个注意,我是把对数据操作的业务层和数据访问层及DataModual封装到DLL中了,查询结构希望通过TDataSource返回,就象C#中的DataSet.
vcl; rtl----------------------------
try again,