打印本文 打印本文 关闭窗口 关闭窗口
TManagedDataSet和DataSetPool的实现
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2767  更新时间:2009/4/23 18:37:43  文章录入:mintao  责任编辑:mintao
sp;  try

    excelobj := CreateOleObject(''''Excel.Application'''');

        excelobj.WorkBooks.Add;

    except

    Exit;

    end;

 

    if FileExists(inadapter.XlsFileName) and inadapter.OverWriteExistFile then

    begin

        DeleteFile(PChar(inadapter.XlsFileName));

    end

    else begin

        excelobj.Quit;

        Exit;

    end;

 

    for i := 0 to inadapter.Count-1 do

    begin

                  

    end;

end;

 

constructor TManagedDataSet.Create(const intype : TManagedDataSetType = Editable);

begin

         inherited Create(nil);

         Self.Connection := DmCommon.Cnn;

    Self.CursorLocation := clUseClient;

    Self.Prepared := True;

    Self.CacheSize := 1000;

    if intype = ReadOnly then

    begin

    Self.CursorType := ctOpenForwardOnly;

    Self.LockType := ltReadOnly;

    end

    else if intype = Editable then

    begin

        Self.CursorType := ctStatic;

    Self.LockType := ltOptimistic;

    end;

 

    _type := intype;

    _bUsed := False;

end;

 

destructor TManagedDataSet.Destroy();

begin

         if Self.Active then

    begin

             Self.Close;

    end;

    if Assigned(_source) then

    begin

             FreeAndNil(_source);

    end;

    inherited Destroy();

end;

 

procedure TManagedDataSet.Use();

begin

    if _bUsed then

    begin

        raise Exception.Create(''''Cannot get a used managed dataset !'''');

    end;

 

    _bUsed := True;

end;

 

procedure TManagedDataSet.Free();

begin

         if Self.Active then

    begin

    Self.Close;

    end;

 

    Self.CommandText := '''''''';

    Self.Parameters.Clear; // 睲埃把计

    Self.MasterFields := ''''''''; // 睲埃琿

    Self.DataSource := nil;

    Self.ExecuteOptions := []; // 睲埃磅︽匡兜

    _bUsed := False;

end;

 

procedure TManagedDataSet.SetDataSetType(const intype : TManagedDataSetType);

begin

    if intype = _type then

    Exit;

 

    if intype = ReadOnly then

    begin

    Self.CursorType := ctOpenForwardOnly;

    Self.LockType := ltReadOnly;

    end

    else if intype = Editable then

    begin

        Self.CursorType := ctStatic;

    Self.LockType := ltOptimistic;

    end;

end;

 

function TManagedDataSet.GetDataSource() : TDataSource;

begin

         if not Assigned(_sour

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口