|
ce) then
begin
_source := TDataSource.Create(nil);
_source.AutoEdit := False;
_source.DataSet := Self;
end;
Result := _source;
end;
end.
unit DataSetPool; // 癘魁栋GlobalVarい承セ摸Ы龟ㄒ跑秖
interface
uses ManagedDataSet, Contnrs, SysUtils, AdoDb, Db, CommonDm;
type
TDataSetPool = class
private
_ads : TObjectList;
function GetCount() : Integer;
public
constructor Create(const ini : Integer = 10);
destructor Destroy(); override;
property Count : Integer read GetCount;
function GetDataSet(const intype : TManagedDataSetType = Editable) : TManagedDataSet;
function GetAdoCommand() : TAdoCommand; // 度TAdoCommand睦パ秸ノ璽砫
end;
implementation
constructor TDataSetPool.Create(const ini : Integer = 10);
begin
_ads := TObjectList.Create;
end;
destructor TDataSetPool.Destroy();
begin
FreeAndNil(_ads);
end;
function TDataSetPool.GetCount() : Integer;
begin
Result := _ads.Count;
end;
function TDataSetPool.GetDataSet(const intype : TManagedDataSetType = Editable) : TManagedDataSet;
var
i : Integer;
begin
Result := nil;
for i := 0 to _ads.Count-1 do
begin
if (not TManagedDataSet(_ads[i]).IsUsed) and (TManagedDataSet(_ads[i]).DataSetType = intype) then
begin
Result := TManagedDataSet(_ads[i]);
Result.Use;
break;
end;
end;
if Result = nil then
begin
_ads.Add(TManagedDataSet.Create(intype));
Result := TManagedDataSet(_ads[_ads.Count-1]);
Result.Use;
end;
end;
function TDataSetPool.GetAdoCommand() : TAdoCommand;
begin
Result := TADOCommand.Create(nil);
Result.Connection := DmCommon.Cnn;
end;
end.
上一页 [1] [2] [3] [4] [VB.NET程序]VB的ShowInTaskbar功能分析以及用VC的实现 [Delphi程序]TFontNameComboBox及TFontSizeComboBox的实现 [Delphi程序]MSN / QQ 中的动画表情 在Delphi中RichEdit的实现… [VB.NET程序]MD5加密算法(16位,32位)的C#,VB的实现 [Web开发]利用JS获取IE客户端IP及MAC的实现 [Web开发]ASP.Net ViewState的实现 [Web开发]vb.net_asp.net跨栏表头_滚动表体的DataGrid的实现 [Web开发]无限分类算法 js 的实现 [JAVA开发]关于UDDI的实现 [SyBase]InnoDB 中文参考手册 --- 10 multiversioning 的实…
|