F
firstshine
Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序有一个datamodule,里面有adoconnection,adoquery,datasetprovider;
程序还有一个Form,里面有clientdataset;
但是我不明白的是怎么将clientdataset的providername设成datamodule中的datasetprovider?
代码如下:
unit uDataModule;
interface
uses
SysUtils, Classes, DB, ADODB, Provider, DBTables;
type
TdmDatabase = class(TDataModule)
adocAccess: TADOConnection;
DatasetProvider: TDataSetProvider;
adoQuery: TADOQuery;
private
Published
Public
end;
//==============================================================
unit uRouteMake;
interface
uses
uDataModule, ......
type
TRouteMake = class(TNonMDIChild)
DBEdit1: TDBEdit;
DBMemo1: TDBMemo;
cdsRoute: TClientDataSet;
private
{ Private declarations }
public
Constructor Create(AOwner:TComponent);override;
end;
implementation
{$R *.dfm}
{ TRouteMake }
constructor TRouteMake.Create(AOwner: TComponent;
begin
inherited Create(AOwner);
cdsRoute.ProviderName:='DatasetProvider';
cdsRoute.CommandText:='select missionname from mission';
cdsTemp.Open;
//出错,错误信息为cdsRoute:Missing data provider or data packet.
//换成cdsRoute.ProviderName:='uDataModule.DatasetProvider'也不行
end;
程序还有一个Form,里面有clientdataset;
但是我不明白的是怎么将clientdataset的providername设成datamodule中的datasetprovider?
代码如下:
unit uDataModule;
interface
uses
SysUtils, Classes, DB, ADODB, Provider, DBTables;
type
TdmDatabase = class(TDataModule)
adocAccess: TADOConnection;
DatasetProvider: TDataSetProvider;
adoQuery: TADOQuery;
private
Published
Public
end;
//==============================================================
unit uRouteMake;
interface
uses
uDataModule, ......
type
TRouteMake = class(TNonMDIChild)
DBEdit1: TDBEdit;
DBMemo1: TDBMemo;
cdsRoute: TClientDataSet;
private
{ Private declarations }
public
Constructor Create(AOwner:TComponent);override;
end;
implementation
{$R *.dfm}
{ TRouteMake }
constructor TRouteMake.Create(AOwner: TComponent;
begin
inherited Create(AOwner);
cdsRoute.ProviderName:='DatasetProvider';
cdsRoute.CommandText:='select missionname from mission';
cdsTemp.Open;
//出错,错误信息为cdsRoute:Missing data provider or data packet.
//换成cdsRoute.ProviderName:='uDataModule.DatasetProvider'也不行
end;