Custom DataSet and write data

xiaoxiao2021-03-06  64

A new DataSet, and added data: prepareTablefunction TFrm_Print.CreateTableInMemory (const AFieldDefs: TFieldDefs): TDataSet; var TempTable: TClientDataSet; begin TempTable: = nil; Result: = nil; if AFieldDefs <> nil then begin try TempTable: = TClientDataSet. Create (Application); Temptable.fielddefs.assign (AfieldDefs); Temptable.created; Result: = (Temptable as TdataSet); Except if Temptable <> nil damiltable.free; Raise; End;

procedure TFrm_Print.CreateDataSet (var gDataSet: Tdataset); var ADataSet: TDataSet; begin try if assigned (gDataSet) then gDataSet.free; except end; ADataSet: = TDataSet.Create (Self); try with ADataSet.FieldDefs do begin add ( 'ORDERNO', FTINTEGER; Add ('prjName', ftstring, 200); add ('srcprice', ftfloat); end; gdataset: = CreateTableInMemory (adataset.fielddefs); gdataset.open; finally adataset.Free; end; END;

procedure Tfrm_GoodsMg.prepareTable (var gDataSet: Tdataset); procedure prepareDataSet; begin {while not data source .eof do begin gDataSet.append; gDataSet.fieldbyname ( 'OrderNo') asInteger:. = I_Value; gDataSet.fieldbyname ( 'prjName') .sstring: = a_value; gdataset.fieldbyname ('ORDERNO'). Asfloat: = D_Value; gdataset.post; data source .Next; end;} end; begin createDataSet; preparedataset;

Procedure getMyDataSet () var mydataset: tdatasetbegin preparetable (MyDataSet); mydataset.free; end;

转载请注明原文地址:https://www.9cbs.com/read-118815.html

New Post(0)